spejstore-new/auth/pipeline.py

18 lines
538 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:
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):
return associate_by_email(backend, {
'email': details.get('personal_email'),
}, user, *args, **kwargs)