Добавлено сравнение по хешу пароля в функцию check_auth

This commit is contained in:
Andrei 2022-10-19 00:02:34 +05:00
parent 239c03eefa
commit 1c4e74c2ca
2 changed files with 4 additions and 1 deletions

View File

@ -29,5 +29,8 @@ class User(SqlAlchemyBase, UserMixin):
def check_password(self, password):
return check_password_hash(self.password, password)
def check_hash_password(self, hash_password):
return True if self.password == hash_password else False
def set_password(self, password):
self.password = generate_password_hash(password)

View File

@ -742,7 +742,7 @@ def check_auth():
session = db_session.create_session()
user = session.query(User).filter(User.email == email).first()
if user:
if user.check_password(password):
if user.check_password(password) or user.check_hash_password(password):
return make_response(jsonify({
'key': '',
'name': user.name,