Making main changes on Tokens and other necessity
Browse files- auth/route.py +2 -2
- auth/services.py +3 -0
auth/route.py
CHANGED
@@ -10,11 +10,11 @@ router = APIRouter(
|
|
10 |
responses={404: {"description": "Not found"}},
|
11 |
)
|
12 |
|
13 |
-
@router.post("/token", status_code=status.HTTP_200_OK)
|
14 |
async def authenticate_user(data: OAuth2PasswordRequestForm = Depends(), db: Session = Depends(get_db)):
|
15 |
return await get_token(data, db)
|
16 |
|
17 |
|
18 |
-
@router.post("/refresh", status_code=status.HTTP_200_OK)
|
19 |
async def refresh_token(refresh_token: str = Header(...), db: Session = Depends(get_db)):
|
20 |
return await get_refresh_token(token=refresh_token, db=db)
|
|
|
10 |
responses={404: {"description": "Not found"}},
|
11 |
)
|
12 |
|
13 |
+
@router.post("/token/", status_code=status.HTTP_200_OK)
|
14 |
async def authenticate_user(data: OAuth2PasswordRequestForm = Depends(), db: Session = Depends(get_db)):
|
15 |
return await get_token(data, db)
|
16 |
|
17 |
|
18 |
+
@router.post("/refresh/", status_code=status.HTTP_200_OK)
|
19 |
async def refresh_token(refresh_token: str = Header(...), db: Session = Depends(get_db)):
|
20 |
return await get_refresh_token(token=refresh_token, db=db)
|
auth/services.py
CHANGED
@@ -42,6 +42,9 @@ async def get_refresh_token(token: str, db):
|
|
42 |
detail="Invalid Token",
|
43 |
headers={"WWW-Authenticate": "Bearer"}
|
44 |
)
|
|
|
|
|
|
|
45 |
|
46 |
def _verify_user_access(user: User):
|
47 |
if not user.is_active:
|
|
|
42 |
detail="Invalid Token",
|
43 |
headers={"WWW-Authenticate": "Bearer"}
|
44 |
)
|
45 |
+
_verify_user_access(user=user)
|
46 |
+
|
47 |
+
return await _get_user_token(user=user, refresh_token=True)
|
48 |
|
49 |
def _verify_user_access(user: User):
|
50 |
if not user.is_active:
|