feat: features for bad internet connections

This commit is contained in:
2025-02-20 08:52:48 +01:00
parent 1a1b44743a
commit 8e91724462
2 changed files with 9 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ from db import engine, User
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from pydantic_settings import BaseSettings, SettingsConfigDict
from passlib.context import CryptContext
from sqlalchemy.exc import OperationalError
class Config(BaseSettings):
@@ -47,10 +48,13 @@ def get_password_hash(password):
def get_user(username: str | None):
if username:
with Session(engine) as session:
return session.exec(
select(User).where(User.username == username)
).one_or_none()
try:
with Session(engine) as session:
return session.exec(
select(User).where(User.username == username)
).one_or_none()
except OperationalError:
return
def authenticate_user(username: str, password: str):