fixing DQ issues

This commit is contained in:
2025-09-14 15:47:38 +02:00
parent 3eb18ef91e
commit 0ce708cf09
27 changed files with 430 additions and 214 deletions

View File

@@ -1,3 +1,12 @@
# app/services/auth_service.py
"""Summary description ....
This module provides classes and functions for:
- ....
- ....
- ....
"""
import logging
from typing import Any, Dict, Optional
@@ -12,9 +21,10 @@ logger = logging.getLogger(__name__)
class AuthService:
"""Service class for authentication operations following the application's service pattern"""
"""Service class for authentication operations following the application's service pattern."""
def __init__(self):
"""Class constructor."""
self.auth_manager = AuthManager()
def register_user(self, db: Session, user_data: UserRegister) -> User:
@@ -62,7 +72,7 @@ class AuthService:
def login_user(self, db: Session, user_credentials: UserLogin) -> Dict[str, Any]:
"""
Login user and return JWT token with user data
Login user and return JWT token with user data.
Args:
db: Database session
@@ -90,33 +100,33 @@ class AuthService:
return {"token_data": token_data, "user": user}
def get_user_by_email(self, db: Session, email: str) -> Optional[User]:
"""Get user by email"""
"""Get user by email."""
return db.query(User).filter(User.email == email).first()
def get_user_by_username(self, db: Session, username: str) -> Optional[User]:
"""Get user by username"""
"""Get user by username."""
return db.query(User).filter(User.username == username).first()
def email_exists(self, db: Session, email: str) -> bool:
"""Check if email already exists"""
"""Check if email already exists."""
return db.query(User).filter(User.email == email).first() is not None
def username_exists(self, db: Session, username: str) -> bool:
"""Check if username already exists"""
"""Check if username already exists."""
return db.query(User).filter(User.username == username).first() is not None
def authenticate_user(
self, db: Session, username: str, password: str
) -> Optional[User]:
"""Authenticate user with username/password"""
"""Authenticate user with username/password."""
return self.auth_manager.authenticate_user(db, username, password)
def create_access_token(self, user: User) -> Dict[str, Any]:
"""Create access token for user"""
"""Create access token for user."""
return self.auth_manager.create_access_token(user)
def hash_password(self, password: str) -> str:
"""Hash password"""
"""Hash password."""
return self.auth_manager.hash_password(password)