Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions openwisp_users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,14 @@ def get_user(self, obj):
admin.site.unregister(EmailAddress)

if allauth_settings.SOCIALACCOUNT_ENABLED:
for model in [
("socialaccount", "SocialApp"),
socialaccount_models = [
("socialaccount", "SocialToken"),
("socialaccount", "SocialAccount"),
]:
]
# Allow managing secrets if OAuth/SAML is enabled
if not app_settings.SOCIALACCOUNT_ADMIN_NEEDED:
socialaccount_models.append(("socialaccount", "SocialApp"))
for model in socialaccount_models:
model_class = apps.get_model(*model)
if admin.site.is_registered(model_class):
admin.site.unregister(model_class)
Expand Down
9 changes: 9 additions & 0 deletions openwisp_users/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,12 @@
"openwisp_users.views.AutocompleteJsonView",
),
)

# if OAuth/SAML is enabled, allow manging keys/secrets
if any(
app.startswith("allauth.socialaccount.providers") for app in settings.INSTALLED_APPS
): # pragma: no cover
SOCIALACCOUNT_ADMIN_NEEDED = True
# otherwise hide the socialaccount admin (not needed)
else:
SOCIALACCOUNT_ADMIN_NEEDED = False
Loading