add authorization and admin role

This commit is contained in:
2025-07-13 17:19:52 +05:00
parent e328fd4100
commit b6901ddf7b
9 changed files with 221 additions and 6 deletions

12
password_utils.py Normal file
View File

@ -0,0 +1,12 @@
from passlib.context import CryptContext
# Инициализация контекста для хеширования паролей
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
def verify_password(plain_password, hashed_password):
"""Проверяет, соответствует ли пароль хешу"""
return pwd_context.verify(plain_password, hashed_password)
def get_password_hash(password):
"""Создаёт хеш пароля"""
return pwd_context.hash(password)