Spaces:
Running
Running
added logout
Browse files- app.py +2 -2
- tokenManagement.py +1 -1
app.py
CHANGED
@@ -312,7 +312,7 @@ def signUp(user:UserBody):
|
|
312 |
|
313 |
|
314 |
@app.post("/auth/logout",tags=["Authentication"])
|
315 |
-
def
|
316 |
|
317 |
token = authorization.split("Bearer ")[-1]
|
318 |
|
@@ -321,7 +321,7 @@ def signUp(refresh:Token,authorization: str = Header(...)):
|
|
321 |
if is_valid != True: # Example check
|
322 |
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")
|
323 |
|
324 |
-
result =
|
325 |
if result ==True:
|
326 |
return {"content": f"successful"}
|
327 |
else:
|
|
|
312 |
|
313 |
|
314 |
@app.post("/auth/logout",tags=["Authentication"])
|
315 |
+
def logout(refresh:Token,authorization: str = Header(...)):
|
316 |
|
317 |
token = authorization.split("Bearer ")[-1]
|
318 |
|
|
|
321 |
if is_valid != True: # Example check
|
322 |
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")
|
323 |
|
324 |
+
result = logout_func(db_uri=MONGO_URI,refresh_token= refresh.refreshToken)
|
325 |
if result ==True:
|
326 |
return {"content": f"successful"}
|
327 |
else:
|
tokenManagement.py
CHANGED
@@ -149,7 +149,7 @@ def verify_access_token(db_uri: str, user_id: str, access_token: str) -> bool:
|
|
149 |
|
150 |
|
151 |
|
152 |
-
def
|
153 |
from pymongo import MongoClient
|
154 |
current_time = datetime.datetime.now()
|
155 |
expire_at = current_time + datetime.timedelta(days=30)
|
|
|
149 |
|
150 |
|
151 |
|
152 |
+
def logout_func(db_uri: str, refresh_token: str) -> str:
|
153 |
from pymongo import MongoClient
|
154 |
current_time = datetime.datetime.now()
|
155 |
expire_at = current_time + datetime.timedelta(days=30)
|