correction of the auth service

main
Anaz 2025-02-25 14:15:18 +04:00
parent 89436bd8f8
commit 57ff496844
2 changed files with 2 additions and 5 deletions

View File

@ -1,7 +1,7 @@
from datetime import datetime, timedelta
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from fastapi import APIRouter, HTTPException, status, Body
from fastapi import APIRouter, Depends, HTTPException, status, Body
from fastapi.responses import JSONResponse
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from sqlalchemy import update, select
@ -31,7 +31,7 @@ async def signup(user: UserCreate):
return await UserService.create_user(user, db)
@router.post("/token", response_model=Token, summary="Login and get access token")
async def login_for_access_token(form_data: OAuth2PasswordRequestForm = Body(...)):
async def login_for_access_token(form_data: OAuth2PasswordRequestForm = Depends()):
async with get_db() as db:
user = await AuthService.authenticate_user(form_data.username, form_data.password, db)
logger.info(f"User {form_data.username} logged in")

View File

@ -120,9 +120,6 @@ class AuthService:
role_result = await db.execute(role_query)
role_data = role_result.mappings().all()
if not role_data:
raise credentials_exception
role = {
"id": role_data[0]["id"],
"name": role_data[0]["name"],