1
0
Fork 0
spejstore-new/auth/pipeline.py

24 lines
594 B
Python
Raw Normal View History

2019-01-10 12:33:45 +00:00
from social_core.pipeline.social_auth import associate_by_email
from django.contrib.auth.models import Group
2019-01-10 12:33:45 +00:00
def staff_me_up(backend, details, response, uid, user, *args, **kwargs):
user.is_staff = True
try:
2024-08-27 20:55:16 +00:00
user.groups.set([Group.objects.get(name="hsmember")])
except Group.DoesNotExist:
pass
user.save()
2019-01-10 12:33:45 +00:00
def associate_by_personal_email(backend, details, user=None, *args, **kwargs):
2023-07-11 13:34:35 +00:00
return associate_by_email(
backend,
{
"email": details.get("personal_email"),
},
user,
*args,
**kwargs
)