Testys commited on
Commit
e635cfe
1 Parent(s): 104a928

Making a commit for creating access token for face recognition means

Browse files
Files changed (1) hide show
  1. users/routes.py +3 -2
users/routes.py CHANGED
@@ -2,7 +2,7 @@ from fastapi import APIRouter, status, Depends, Request, UploadFile, File, HTTPE
2
  from fastapi.responses import JSONResponse
3
  from sqlalchemy.orm import Session
4
  from core.database import get_db
5
- from core.security import get_current_user, create_access_token
6
  from users.schemas import UserCreate, UserBase, UserEmbeddingsBase, User, UserUpdate
7
  from users.services import create_user_account, create_user_embeddings, update_user, update_user_embeddings, get_user_by_id, get_user_by_email
8
  from services.facial_processing import FacialProcessing
@@ -109,7 +109,8 @@ async def face_login(file: UploadFile = File(...), db: Session = Depends(get_db)
109
 
110
  access_token_expires = timedelta(minutes=int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", "30")))
111
  payload = {"id": user.id, "sub": user.email}
112
- token = await get_token(payload, db)
 
113
 
114
  os.remove(image_path)
115
  return JSONResponse(content=token.dict(), status_code=status.HTTP_200_OK)
 
2
  from fastapi.responses import JSONResponse
3
  from sqlalchemy.orm import Session
4
  from core.database import get_db
5
+ from core.security import get_current_user, create_refresh_token, create_access_token
6
  from users.schemas import UserCreate, UserBase, UserEmbeddingsBase, User, UserUpdate
7
  from users.services import create_user_account, create_user_embeddings, update_user, update_user_embeddings, get_user_by_id, get_user_by_email
8
  from services.facial_processing import FacialProcessing
 
109
 
110
  access_token_expires = timedelta(minutes=int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", "30")))
111
  payload = {"id": user.id, "sub": user.email}
112
+ access_token = await create_access_token(data=payload, expiry=access_token_expires)
113
+ refresh_token = await create_refresh_token(data=payload)
114
 
115
  os.remove(image_path)
116
  return JSONResponse(content=token.dict(), status_code=status.HTTP_200_OK)