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:
parent
65ac18fb8b
commit
4143144601
|
@ -1,13 +1,17 @@
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
from bsition.api.endpoints import documents, token, tables, users
|
from bsition.api.endpoints import documents, tables, token, users
|
||||||
from bsition.api.utils.security import get_current_user
|
from bsition.api.utils.security import get_current_user
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
router.include_router(token.router)
|
router.include_router(token.router)
|
||||||
router.include_router(documents.router, prefix="/documents", dependencies=[Depends(get_current_user)])
|
router.include_router(
|
||||||
|
documents.router, prefix="/documents", dependencies=[Depends(get_current_user)]
|
||||||
|
)
|
||||||
router.include_router(users.router, prefix="/users")
|
router.include_router(users.router, prefix="/users")
|
||||||
router.include_router(tables.router, prefix="/tables", dependencies=[Depends(get_current_user)])
|
router.include_router(
|
||||||
|
tables.router, prefix="/tables", dependencies=[Depends(get_current_user)]
|
||||||
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from fastapi import APIRouter, HTTPException, Depends
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
from fastapi.security import OAuth2PasswordRequestForm
|
from fastapi.security import OAuth2PasswordRequestForm
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ def login(form: OAuth2PasswordRequestForm = Depends()):
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content={
|
content={
|
||||||
"access_token": write_token({"sub": form.username}),
|
"access_token": write_token({"sub": form.username}),
|
||||||
"token_type": "bearer"},
|
"token_type": "bearer",
|
||||||
|
},
|
||||||
status_code=202,
|
status_code=202,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from fastapi import APIRouter, HTTPException, Request, Depends
|
from fastapi import APIRouter, Depends, HTTPException, Request
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
from bsition.api.models.user import User
|
from bsition.api.models.user import User
|
||||||
|
|
|
@ -10,6 +10,7 @@ def expire_date(days: int):
|
||||||
|
|
||||||
# TODO: migrar a librería 'jose'
|
# TODO: migrar a librería 'jose'
|
||||||
|
|
||||||
|
|
||||||
def write_token(data: dict):
|
def write_token(data: dict):
|
||||||
return encode(
|
return encode(
|
||||||
payload={**data, "exp": expire_date(1)}, key=getenv("SECRET"), algorithm="HS256"
|
payload={**data, "exp": expire_date(1)}, key=getenv("SECRET"), algorithm="HS256"
|
||||||
|
|
Loading…
Reference in New Issue