API - minor refacto

This commit is contained in:
Sam
2022-05-23 13:04:01 +02:00
parent 0ee28d7331
commit c13e9e0286
3 changed files with 18 additions and 15 deletions

View File

@ -1,9 +1,7 @@
import secrets
from typing import Optional, Tuple
from flask import current_app
from fittrackee import bcrypt, db
from fittrackee import db
from ..exceptions import InvalidEmailException, UserNotFoundException
from ..models import User
@ -33,9 +31,7 @@ class UserManagerService:
@staticmethod
def _reset_user_password(user: User) -> str:
new_password = secrets.token_urlsafe(30)
user.password = bcrypt.generate_password_hash(
new_password, current_app.config.get('BCRYPT_LOG_ROUNDS')
).decode()
user.password = user.generate_password_hash(new_password)
return new_password
@staticmethod