|
@ -7,14 +7,13 @@ from atheneum.service import authentication_service |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def register(name: str, password: str, role: str) -> User: |
|
|
def register(name: str, password: str, role: str) -> User: |
|
|
password_hash, password_revision = authentication_service.get_password_hash( |
|
|
|
|
|
password) |
|
|
|
|
|
|
|
|
pw_hash, pw_revision = authentication_service.get_password_hash(password) |
|
|
|
|
|
|
|
|
new_user = User( |
|
|
new_user = User( |
|
|
name=name, |
|
|
name=name, |
|
|
role=role, |
|
|
role=role, |
|
|
password_hash=password_hash, |
|
|
|
|
|
password_revision=password_revision, |
|
|
|
|
|
|
|
|
password_hash=pw_hash, |
|
|
|
|
|
password_revision=pw_revision, |
|
|
creation_time=datetime.now(), |
|
|
creation_time=datetime.now(), |
|
|
version=0) |
|
|
version=0) |
|
|
db.session.add(new_user) |
|
|
db.session.add(new_user) |
|
@ -38,10 +37,10 @@ def update_last_login_time(user: User): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_password(user: User, password: str): |
|
|
def update_password(user: User, password: str): |
|
|
password_hash, password_revision = authentication_service.get_password_hash( |
|
|
|
|
|
|
|
|
pw_hash, pw_revision = authentication_service.get_password_hash( |
|
|
password) |
|
|
password) |
|
|
user.password_hash = password_hash |
|
|
|
|
|
user.password_revision = password_revision |
|
|
|
|
|
|
|
|
user.password_hash = pw_hash |
|
|
|
|
|
user.password_revision = pw_revision |
|
|
db.session.commit() |
|
|
db.session.commit() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|