Files
saas_backend/app/controllers/auth/auth_controller.py
T
2026-01-17 14:18:00 +05:30

62 lines
2.0 KiB
Python

from sqlalchemy.orm import Session
from app.schemas.auth.auth_schema import (
UserSignup,
UserSignin,
UserUpdate,
ResetPassword,
RefreshTokenRequest,
ForgotPasswordRequest,
VerifyOTPRequest,
ResetPasswordWithOTP,
)
from app.services.auth.auth_service import AuthService
from app.models.auth.user_model import User
import uuid
class AuthController:
@staticmethod
def signup(db: Session, user_data: UserSignup, tenant_id: uuid.UUID = None):
return AuthService.create_user(db, user_data, tenant_id)
@staticmethod
def signin(db: Session, signin_data: UserSignin):
return AuthService.signin(db, signin_data)
@staticmethod
def refresh_token(db: Session, token_data: RefreshTokenRequest):
return AuthService.refresh_access_token(db, token_data.refresh_token)
@staticmethod
def update_user(
db: Session, user_id: uuid.UUID, user_data: UserUpdate, current_user: User
):
return AuthService.update_user(db, user_id, user_data, current_user)
@staticmethod
def reset_password(db: Session, user: User, password_data: ResetPassword):
return AuthService.reset_password(
db, user, password_data.old_password, password_data.new_password
)
@staticmethod
def logout(current_user: User):
return AuthService.logout(current_user)
@staticmethod
def me(db: Session, current_user: User):
return AuthService.me(db, current_user)
@staticmethod
def forgot_password(db: Session, request: ForgotPasswordRequest):
return AuthService.forgot_password(db, request.email)
@staticmethod
def verify_otp(db: Session, request: VerifyOTPRequest):
return AuthService.verify_otp(db, request.email, request.otp)
@staticmethod
def reset_password_with_otp(db: Session, request: ResetPasswordWithOTP):
return AuthService.reset_password_with_otp(
db, request.email, request.otp, request.new_password
)