Browse Source

Batch user save calls

pull/675/head
Setu Shah 4 years ago
parent
commit
68fdfb2b7b
1 changed files with 12 additions and 2 deletions
  1. 14
      app/server/social_auth.py

14
app/server/social_auth.py

@ -96,12 +96,17 @@ def fetch_okta_oauth2_permissions(strategy, details, user=None, is_new=False, *a
is_superuser = admin_group_name in response.get("groups", [])
is_staff = admin_group_name in response.get("groups", [])
user_changed = False
if user.is_superuser != is_superuser:
user.is_superuser = is_superuser
user.save()
user_changed = user_changed or True
if user.is_staff != is_staff:
user.is_staff = is_staff
user_changed = user_changed or True
if user_changed:
user.save()
@ -124,10 +129,15 @@ def fetch_okta_openidconnect_permissions(strategy, details, user=None, is_new=Fa
is_superuser = admin_group_name in response.get("groups", [])
is_staff = admin_group_name in response.get("groups", [])
user_changed = False
if user.is_superuser != is_superuser:
user.is_superuser = is_superuser
user.save()
user_changed = user_changed or True
if user.is_staff != is_staff:
user.is_staff = is_staff
user_changed = user_changed or True
if user_changed:
user.save()
Loading…
Cancel
Save