2019-01-10 12:33:45 +00:00
|
|
|
from social_core.pipeline.social_auth import associate_by_email
|
2020-05-28 19:53:58 +00:00
|
|
|
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
|
2020-05-28 19:53:58 +00:00
|
|
|
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)
|