FEATURE: allow site owners to disable impersonation (#20783)

Site owners can now disable impersonation using the global setting
`allow_impersonation` (Eg: DISCOURSE_ALLOW_IMPERSONATION: false)

see:

https://meta.discourse.org/t/thoughts-about-impersonate-user/258795
This commit is contained in:
Sam
2023-03-23 15:16:05 +11:00
committed by GitHub
parent 4fe79ccc79
commit d87e78616d
3 changed files with 9 additions and 2 deletions

View File

@ -297,7 +297,7 @@ class Guardian
# Can we impersonate this user?
def can_impersonate?(target)
target &&
GlobalSetting.allow_impersonation && target &&
# You must be an admin to impersonate
is_admin? &&
# You may not impersonate other admins unless you are a dev