Refactor User class to use property decorator for

password_hash
This commit is contained in:
Théophile Diot 2023-11-28 17:03:14 +01:00
parent c1e25a64af
commit bf5dadb431
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06

View file

@ -1,6 +1,5 @@
#!/usr/bin/python3
from functools import cached_property
from typing import Optional
from flask_login import UserMixin
from bcrypt import checkpw, hashpw, gensalt
@ -15,7 +14,7 @@ class User(UserMixin):
self.__password = password_hash or hashpw(password.encode("utf-8"), gensalt()) # type: ignore
@cached_property
@property
def password_hash(self) -> bytes:
"""
Get the password hash