From c72d83a6c7ca891e37ea07aabcc4de7d8a4533db Mon Sep 17 00:00:00 2001 From: RaisSabeAndrade Date: Sun, 10 Dec 2023 18:02:41 -0300 Subject: [PATCH] =?UTF-8?q?Coment=C3=A1rios=20para=20authController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/authController.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/controller/authController.py b/src/controller/authController.py index 80519a4..16c59db 100644 --- a/src/controller/authController.py +++ b/src/controller/authController.py @@ -15,6 +15,7 @@ prefix="/auth" ) + # Retorna conexões disponíveis @auth.get("/vinculo", response_model=authSchema.Connections) def get_connection(): connections = [member.value for member in enumeration.UserConnection] @@ -64,6 +65,7 @@ async def login(data: authSchema.UserLogin, db: Session = Depends(get_db)): return JSONResponse(status_code=200, content={ "access_token": access_token, "refresh_token": refresh_token, "token_type": "bearer" }) + # Recebe os dados do usuário provenientes de uma autenticação social @auth.post("/login/social") async def login_social(user: authSchema.UserSocial, db: Session = Depends(get_db)): existing_user = userRepository.get_user_by_email(db, user.email) @@ -78,7 +80,8 @@ async def login_social(user: authSchema.UserSocial, db: Session = Depends(get_db refresh_token = security.create_refresh_token(data={ "id": existing_user.id }) return JSONResponse(status_code=200, content={ "access_token": access_token, "refresh_token": refresh_token, "token_type": "bearer", "is_new_user": False }) - + + # trata da renovação de tokens de acesso @auth.post("/refresh", response_model=authSchema.RefreshTokenResponse) def refresh_token(token: dict = Depends(security.verify_token)): access_token=security.create_access_token(token) @@ -96,6 +99,7 @@ async def send_new_code(data: authSchema.SendNewCode, db: Session = Depends(get_ res = await send_mail.send_verification_code(email=data.email, code=user.activation_code) return JSONResponse(status_code=201, content={ "status": "success" }) + # Recebe dados de validação de conta @auth.patch('/activate-account') async def validate_account(data: authSchema.AccountValidation, db: Session = Depends(get_db)): user = userRepository.get_user_by_email(db, data.email)