mirror of
https://github.com/nikdoof/django-testauth.git
synced 2025-12-18 12:19:29 +00:00
Added support to auto-pull groups from Auth
This commit is contained in:
7
auth.py
7
auth.py
@@ -36,6 +36,7 @@ class DredditAuthBackend:
|
||||
|
||||
if 'auth' in obj and obj['auth'] == 'ok':
|
||||
email = obj['email']
|
||||
groups = obj['groups']
|
||||
valid = True
|
||||
|
||||
if valid:
|
||||
@@ -45,6 +46,12 @@ class DredditAuthBackend:
|
||||
user.save()
|
||||
if email:
|
||||
user.email = email
|
||||
|
||||
if hasattr(settings, 'DREDDIT_AUTH_CREATE_GROUPS') and settings.DREDDIT_AUTH_CREATE_GROUPS:
|
||||
for g in groups:
|
||||
group, created = Group.objects.get_or_create(name=g['name']):
|
||||
user.groups.add(group)
|
||||
|
||||
return user
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user