-
Notifications
You must be signed in to change notification settings - Fork 3
/
adapters.py
23 lines (17 loc) · 895 Bytes
/
adapters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
from allauth.account.adapter import DefaultAccountAdapter
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
from dotenv import load_dotenv
load_dotenv()
class CustomAccountAdapter(DefaultAccountAdapter):
def is_open_for_signup(self, request):
return False # No email/password signups allowed
class CustomSocialAccountAdapter(DefaultSocialAccountAdapter):
def is_open_for_signup(self, request, sociallogin):
u = sociallogin.user
# Optionally, set as staff now as well.
# This is useful if you are using this for the Django Admin login.
# Be careful with the staff setting, as some providers don't verify
# email address, so that could be considered a security flaw.
# u.is_staff = u.email.split('@')[1] == "customdomain.com"
return u.email.split("@")[1] == os.getenv("INSTITUTE_DOMAIN")