Added some type annotation
The web layer uses string IDs, whereas the API layer uses ObjectIDs. Those annotations make it a bit more explicit what is used where.
This commit is contained in:
parent
080d98f57c
commit
82437724cc
@ -1,6 +1,7 @@
|
|||||||
"""Authentication code common to the web and api modules."""
|
"""Authentication code common to the web and api modules."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import typing
|
||||||
|
|
||||||
from flask import session
|
from flask import session
|
||||||
import flask_login
|
import flask_login
|
||||||
@ -13,15 +14,15 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class UserClass(flask_login.UserMixin):
|
class UserClass(flask_login.UserMixin):
|
||||||
def __init__(self, token):
|
def __init__(self, token: typing.Optional[str]):
|
||||||
# We store the Token instead of ID
|
# We store the Token instead of ID
|
||||||
self.id = token
|
self.id = token
|
||||||
self.username = None
|
self.username: str = None
|
||||||
self.full_name = None
|
self.full_name: str = None
|
||||||
self.objectid = None
|
self.objectid: str = None
|
||||||
self.gravatar = None
|
self.gravatar: str = None
|
||||||
self.email = None
|
self.email: str = None
|
||||||
self.roles = []
|
self.roles: typing.List[str] = []
|
||||||
|
|
||||||
def has_role(self, *roles):
|
def has_role(self, *roles):
|
||||||
"""Returns True iff the user has one or more of the given roles."""
|
"""Returns True iff the user has one or more of the given roles."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user