Run pre-commit

Co-authored-by: Ezequiel Bellver <ebellver@itba.edu.ar>
Co-authored-by: Juan Barmasch <jbarmasch@itba.edu.ar>
This commit is contained in:
Santiago Lo Coco 2022-11-29 11:14:56 -03:00
parent ec80c1a96c
commit 0799aea56a
7 changed files with 16 additions and 14 deletions

View File

@ -79,7 +79,7 @@ sh run.sh -a
Puede ir a `http://localhost:8000/docs` para ver el `Swagger`. Notemos que se usó en todo momento `localhost` pues se supone un ambiente de testeo.
Además, cuenta con una colección de `Postman` en [docs/bsition_postman.json](docs/bsition_postman.json). Consulte el siguiente [link](https://learning.postman.com/docs/getting-started/importing-and-exporting-data/) para ver cómo se importa.
Además, cuenta con una colección de `Postman` en [docs/bsition_postman.json](docs/bsition_postman.json). Consulte el siguiente [link](https://learning.postman.com/docs/getting-started/importing-and-exporting-data/) para ver cómo se importa.
En esta colección se muestra, a grandes rasgos, el funcionamiento de la API.

View File

@ -1,7 +1,7 @@
from fastapi import APIRouter
from fastapi.responses import JSONResponse
from bsition.api.endpoints import documents, tables, users, login
from bsition.api.endpoints import documents, login, tables, users
router = APIRouter()

View File

@ -1,8 +1,8 @@
from fastapi import APIRouter, HTTPException
from fastapi.responses import JSONResponse
from bsition.api.utils.jwt import write_token
from bsition.api.models.user import User
from bsition.api.utils.jwt import write_token
from bsition.backend.postgres import get_user_by_username_and_password
router = APIRouter()
@ -12,11 +12,9 @@ router = APIRouter()
def login(user: User):
if get_user_by_username_and_password(user.username, user.password) is not None:
return JSONResponse(
content={
"access_token": write_token(user.dict()),
"token_type": "bearer"
},
status_code=202)
content={"access_token": write_token(user.dict()), "token_type": "bearer"},
status_code=202,
)
else:
raise HTTPException(
status_code=400,

View File

@ -2,7 +2,7 @@ from fastapi import APIRouter
from fastapi.responses import JSONResponse
from bsition.api.middleware.verify_token import VerifyTokenRoute
from bsition.api.models.table import Table, Sort, Filter
from bsition.api.models.table import Filter, Sort, Table
from bsition.backend import postgres
router = APIRouter(route_class=VerifyTokenRoute)

View File

@ -10,7 +10,10 @@ router = APIRouter()
@router.post("")
def create_user(user: User):
if postgres.get_user_by_username_and_password(user.username, user.password) is not None:
if (
postgres.get_user_by_username_and_password(user.username, user.password)
is not None
):
raise HTTPException(
status_code=400,
detail="User already exists.",

View File

@ -1,5 +1,6 @@
from fastapi import FastAPI
from dotenv import load_dotenv
from fastapi import FastAPI
from bsition.api.api import router
app = FastAPI()

View File

@ -286,9 +286,9 @@ def get_user_by_username_and_password(username, password):
conn = get_connection()
cur = conn.cursor()
cur.execute(
sql.SQL("SELECT * FROM users WHERE username = {username} AND password = {password}").format(
username=sql.Literal(username), password=sql.Literal(password)
)
sql.SQL(
"SELECT * FROM users WHERE username = {username} AND password = {password}"
).format(username=sql.Literal(username), password=sql.Literal(password))
)
return cur.fetchone()