Make database, oauth, smtp server, mail verificaiton configurable in .env
This commit is contained in:
parent
9b5fe1627d
commit
712d9a843e
8 changed files with 109 additions and 31 deletions
42
allauth_oauth/provider.py
Normal file
42
allauth_oauth/provider.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# From https://gitlab.crans.org/bde/allauth-note-kfet
|
||||
# Copyright (C) 2022 Amicale des élèves de l'ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from allauth.account.models import EmailAddress
|
||||
from allauth.socialaccount.providers.base import ProviderAccount
|
||||
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
|
||||
|
||||
|
||||
class OAuthAccount(ProviderAccount):
|
||||
def to_str(self):
|
||||
return self.account.extra_data.get("username")
|
||||
|
||||
|
||||
class OAuthProvider(OAuth2Provider):
|
||||
id = "oauth"
|
||||
name = "OAuth"
|
||||
account_class = OAuthAccount
|
||||
|
||||
def extract_uid(self, data):
|
||||
return str(data["username"])
|
||||
|
||||
def extract_common_fields(self, data):
|
||||
return dict(
|
||||
email=data.get("email"),
|
||||
username=data.get("username"),
|
||||
last_name=data.get("last_name"),
|
||||
first_name=data.get("first_name"),
|
||||
)
|
||||
|
||||
def get_default_scope(self):
|
||||
return ["read"]
|
||||
|
||||
def extract_email_addresses(self, data):
|
||||
ret = []
|
||||
email = data.get("email")
|
||||
if email:
|
||||
ret.append(EmailAddress(email=email, verified=True, primary=True))
|
||||
return ret
|
||||
|
||||
|
||||
provider_classes = [OAuthProvider]
|
||||
Loading…
Add table
Add a link
Reference in a new issue