Skip to content

Commit

Permalink
feat: better admin_impersonate strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed May 21, 2021
1 parent bfc0e47 commit d2eada1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/appier_extras/parts/admin/models/account.py
Expand Up @@ -912,8 +912,7 @@ def email_recover(self):
level = 2
)
def impersonate(self):
impersonate = appier.conf("ADMIN_IMPERSONATE", False, cast = bool)
if not impersonate:
if not self.owner.admin_impersonate:
raise appier.SecurityError(message = "Impersonation is not allowed")
self._set_account()

Expand Down
3 changes: 3 additions & 0 deletions src/appier_extras/parts/admin/part.py
Expand Up @@ -94,6 +94,7 @@ def __init__(
self.available = kwargs.get("available", True)
self.open = kwargs.get("open", False)
self.oauth = kwargs.get("oauth", True)
self.impersonate = kwargs.get("impersonate", False)
self.avatar_default = kwargs.get("avatar_default", False)
self.layout = appier.conf("ADMIN_LAYOUT", self.layout)
self.theme = appier.conf("ADMIN_THEME", self.theme)
Expand All @@ -103,6 +104,7 @@ def __init__(
self.available = appier.conf("ADMIN_AVAILABLE", self.available, cast = bool)
self.open = appier.conf("ADMIN_OPEN", self.open, cast = bool)
self.oauth = appier.conf("ADMIN_OAUTH", self.oauth, cast = bool)
self.impersonate = appier.conf("ADMIN_IMPERSONATE", self.impersonate, cast = bool)
self.avatar_default = appier.conf(
"ADMIN_AVATAR_DEFAULT",
self.avatar_default,
Expand Down Expand Up @@ -153,6 +155,7 @@ def load(self):
self.owner.admin_available = self.available
self.owner.admin_open = self.open
self.owner.admin_oauth = self.oauth
self.owner.admin_impersonate = self.impersonate
self.owner.admin_avatar_default = self.avatar_default

self.owner.admin_layout_fluid = "admin/layout.fluid.html.tpl"
Expand Down

0 comments on commit d2eada1

Please sign in to comment.