auth and minor fixes
This commit is contained in:
@@ -11,6 +11,7 @@ from auth.jwtcodec import JWTCodec
|
||||
from auth.tokenstorage import TokenStorage
|
||||
from base.exceptions import InvalidToken
|
||||
from services.auth.users import UserStorage
|
||||
from settings import SESSION_TOKEN_HEADER
|
||||
|
||||
|
||||
class SessionToken:
|
||||
@@ -48,10 +49,12 @@ class JWTAuthenticate(AuthenticationBackend):
|
||||
async def authenticate(
|
||||
self, request: HTTPConnection
|
||||
) -> Optional[Tuple[AuthCredentials, AuthUser]]:
|
||||
if "Auth" not in request.headers:
|
||||
|
||||
if SESSION_TOKEN_HEADER not in request.headers:
|
||||
return AuthCredentials(scopes=[]), AuthUser(user_id=None)
|
||||
|
||||
token = request.headers.get("Auth", "")
|
||||
token = request.headers.get(SESSION_TOKEN_HEADER, "")
|
||||
|
||||
try:
|
||||
payload = await SessionToken.verify(token)
|
||||
except Exception as exc:
|
||||
|
@@ -25,6 +25,8 @@ async def send_auth_email(user, token, lang="ru"):
|
||||
"h:X-Mailgun-Variables": "{ \"token\": \"%s\" }" % token
|
||||
}
|
||||
print('[auth.email] payload: %r' % payload)
|
||||
# debug
|
||||
# print('http://localhost:3000/?modal=auth&mode=confirm-email&token=%s' % token)
|
||||
response = requests.post(
|
||||
api_url,
|
||||
auth=("api", MAILGUN_API_KEY),
|
||||
|
Reference in New Issue
Block a user