Refactor password handling and model typing
Replaced custom password generation and verification logic with a new pkg/password.py module using Argon2 for secure hashing. Updated model field types to use PEP 604 union syntax (e.g., str | None) and improved type annotations. Refactored admin and session routes to use new password utilities and direct model methods for CRUD operations. Removed legacy tool-based password functions and cleaned up .idea project files.
This commit is contained in:
@@ -6,7 +6,7 @@ from fastapi.security import OAuth2PasswordRequestForm
|
||||
from fastapi import APIRouter
|
||||
import jwt, JWT
|
||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||
from tool import verify_password
|
||||
from pkg.password import Password
|
||||
from loguru import logger
|
||||
|
||||
from model.token import Token
|
||||
@@ -35,7 +35,7 @@ async def authenticate_user(session: AsyncSession, username: str, password: str)
|
||||
logger.error("Account or password not set in settings.")
|
||||
return False
|
||||
|
||||
if account.value != username or not verify_password(stored_password.value, password):
|
||||
if account.value != username or not Password.verify(stored_password.value, password):
|
||||
logger.error("Invalid username or password.")
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user