BugFix in verification subsystem

This commit is contained in:
2022-09-24 16:38:17 +03:00
parent 44da6faadd
commit 2c51925827
5 changed files with 108 additions and 26 deletions

View File

@@ -45,10 +45,11 @@ class UserToken(models.Model):
@staticmethod
def get_user_by_token(token: str):
t = UserToken.objects.get(access_token=token)
if t is None:
t = UserToken.objects.filter(access_token=token)
if len(t) == 0:
raise Exception(API_ERROR_INVALID_TOKEN)
return t.user
return t[0].user
def __str__(self):
return self.user.email + ": " + self.access_token[:10] + "..."