1
- from typing import Any , Dict , List , Optional
1
+ from typing import Any , Dict , Optional
2
2
3
3
from django .core .exceptions import ImproperlyConfigured , PermissionDenied
4
4
from django .http import HttpResponse
5
5
6
- from allauth .account .models import EmailAddress
7
6
from allauth .account .utils import get_next_redirect_url , get_request_param
8
7
from allauth .core import context
9
8
from allauth .socialaccount import app_settings
10
9
from allauth .socialaccount .adapter import get_adapter
11
10
from allauth .socialaccount .internal import statekit
12
- from allauth .socialaccount .models import SocialLogin
13
11
from allauth .socialaccount .providers .base .constants import AuthProcess
14
12
15
13
@@ -68,7 +66,7 @@ def redirect(
68
66
"""
69
67
raise NotImplementedError ()
70
68
71
- def verify_token (self , request , token ) -> SocialLogin :
69
+ def verify_token (self , request , token ):
72
70
"""
73
71
Verifies the token, returning a `SocialLogin` instance when valid.
74
72
Raises a `ValidationError` otherwise.
@@ -87,7 +85,7 @@ def wrap_account(self, social_account):
87
85
def get_settings (self ) -> dict :
88
86
return app_settings .PROVIDERS .get (self .id , {})
89
87
90
- def sociallogin_from_response (self , request , response ) -> SocialLogin :
88
+ def sociallogin_from_response (self , request , response ):
91
89
"""
92
90
Instantiates and populates a `SocialLogin` model based on the data
93
91
retrieved in `response`. The method does NOT save the model to the
@@ -178,6 +176,9 @@ def extract_common_fields(self, data) -> dict:
178
176
def cleanup_email_addresses (
179
177
self , email : Optional [str ], addresses : list , email_verified : bool = False
180
178
) -> Optional [str ]:
179
+ # Avoid loading models before adapters have been registered.
180
+ from allauth .account .models import EmailAddress
181
+
181
182
# Move user.email over to EmailAddress
182
183
if email and email .lower () not in [a .email .lower () for a in addresses ]:
183
184
addresses .insert (
@@ -196,7 +197,7 @@ def cleanup_email_addresses(
196
197
email = addresses [0 ].email
197
198
return email
198
199
199
- def extract_email_addresses (self , data ) -> List [ EmailAddress ] :
200
+ def extract_email_addresses (self , data ):
200
201
"""
201
202
For example:
202
203
0 commit comments