spejstore-new/auth/pipeline.py

24 lines
592 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
2018-10-10 17:56:43 +00:00
def staff_me_up(backend, details, response, uid, user, *args, **kwargs):
user.is_staff = True
try:
2023-07-11 13:34:35 +00:00
user.groups.set([Group.objects.get(name="member")])
except Group.DoesNotExist:
pass
2018-10-10 17:56:43 +00:00
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
)