Migrate from sqlmodel to pure sqlalchemy

This commit is contained in:
2025-05-18 22:13:07 +02:00
parent 061a52c90a
commit a0adf281b5
12 changed files with 68 additions and 52 deletions

View File

@ -6,9 +6,11 @@ from typing import cast, Any
import bcrypt
import jwt
from sqlmodel import Session, select
from sqlalchemy import select
from sqlalchemy.orm import Session
from sshecret_admin.core.settings import AdminServerSettings
from .models import User, TokenData
from .exceptions import AuthenticationFailedError
@ -72,7 +74,7 @@ def check_password(plain_password: str, hashed_password: str) -> None:
def authenticate_user(session: Session, username: str, password: str) -> User | None:
"""Authenticate user."""
user = session.exec(select(User).where(User.username == username)).first()
user = session.scalars(select(User).where(User.username == username)).first()
if not user:
return None
if not verify_password(password, user.hashed_password):