Add invitations
This commit is contained in:
parent
29543026ed
commit
600a6af27a
11 changed files with 465 additions and 19 deletions
|
|
@ -16,6 +16,7 @@ with open('private-key.pem') as file:
|
|||
with open('public-key.pem') as file:
|
||||
PUBLIC_KEY = file.read()
|
||||
|
||||
|
||||
@dataclass
|
||||
class JwtUser:
|
||||
_id: ObjectId
|
||||
|
|
@ -41,17 +42,26 @@ class User:
|
|||
admin: bool
|
||||
|
||||
@classmethod
|
||||
def create(cls, email: str, name: str, password: str|bytes, moderator: bool = False, admin: bool = False):
|
||||
def create(
|
||||
cls,
|
||||
email: str,
|
||||
name: str,
|
||||
password: str | bytes,
|
||||
moderator: bool = False,
|
||||
admin: bool = False,
|
||||
):
|
||||
"""Alternate constructor which hashes a given password"""
|
||||
salt = randbytes(32)
|
||||
password_hash = scrypt.hash(password, salt)
|
||||
return cls(_id=None,
|
||||
email=email,
|
||||
name=name,
|
||||
password_hash=password_hash,
|
||||
salt=salt,
|
||||
moderator=moderator,
|
||||
admin=admin)
|
||||
return cls(
|
||||
_id=None,
|
||||
email=email,
|
||||
name=name,
|
||||
password_hash=password_hash,
|
||||
salt=salt,
|
||||
moderator=moderator,
|
||||
admin=admin,
|
||||
)
|
||||
|
||||
@property
|
||||
def document(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue