Beispiel #1
0
def login(payload: AuthRequestSchema, *,
          db: Session = Depends(db_session)) -> Any:
    identity, password = dict(payload).values(
    )  # Desestruturando (Unpacking) os valores do Request Body payload

    user = UsersService.get_user(db, identity=identity)
    AuthService.validate_access(user, password)
    token = AuthService.get_token(user.id)

    return {'token': token, 'entity': user.entity}
Beispiel #2
0
def validate_token(payload: TokenSchema, *,
                   db: Session = Depends(db_session)) -> Any:
    user_id = AuthService.validate_token(payload.token)
    user = UsersService.get_user(db, identity=user_id)

    return {'entity': user.entity}