checks enabled
This commit is contained in:
parent
9e94f75f7e
commit
18e5cd4747
|
@ -27,12 +27,12 @@ class JWTAuthenticate(AuthenticationBackend):
|
||||||
if not token:
|
if not token:
|
||||||
print("[auth.authenticate] no token in header %s" % SESSION_TOKEN_HEADER)
|
print("[auth.authenticate] no token in header %s" % SESSION_TOKEN_HEADER)
|
||||||
return AuthCredentials(scopes={}, error_message=str("no token")), AuthUser(
|
return AuthCredentials(scopes={}, error_message=str("no token")), AuthUser(
|
||||||
user_id=None
|
user_id=None, username=''
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(token.split('.')) > 1:
|
if len(token.split('.')) > 1:
|
||||||
payload = await SessionToken.verify(token)
|
payload = await SessionToken.verify(token)
|
||||||
user = None
|
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
try:
|
try:
|
||||||
user = (
|
user = (
|
||||||
|
@ -52,12 +52,12 @@ class JWTAuthenticate(AuthenticationBackend):
|
||||||
scopes=scopes,
|
scopes=scopes,
|
||||||
logged_in=True
|
logged_in=True
|
||||||
),
|
),
|
||||||
AuthUser(user_id=user.id),
|
AuthUser(user_id=user.id, username=''),
|
||||||
)
|
)
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return AuthCredentials(scopes={}, error_message=str('Invalid token')), AuthUser(user_id=None)
|
return AuthCredentials(scopes={}, error_message=str('Invalid token')), AuthUser(user_id=None, username='')
|
||||||
|
|
||||||
|
|
||||||
def login_required(func):
|
def login_required(func):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user