Skip to content

Commit

Permalink
Comentários para authController
Browse files Browse the repository at this point in the history
  • Loading branch information
RaissaAndradeS committed Dec 10, 2023
1 parent 370b23c commit c72d83a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/controller/authController.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit c72d83a

Please sign in to comment.