add TOKEN_TIME and DEFAULT_EMAIL

This commit is contained in:
hay-kot
2021-04-19 19:36:45 -08:00
parent 4a6805479c
commit f14e1e536c
8 changed files with 20 additions and 13 deletions

View File

@@ -32,7 +32,7 @@ def get_token(
headers={"WWW-Authenticate": "Bearer"},
)
access_token = security.create_access_token(dict(sub=email), timedelta(hours=2))
access_token = security.create_access_token(dict(sub=email))
return SnackResponse.success(
"User Successfully Logged In",
{"access_token": access_token, "token_type": "bearer"},
@@ -42,5 +42,5 @@ def get_token(
@router.get("/refresh")
async def refresh_token(current_user: UserInDB = Depends(get_current_user)):
""" Use a valid token to get another token"""
access_token = security.create_access_token(data=dict(sub=current_user.email), expires_delta=timedelta(hours=1))
access_token = security.create_access_token(data=dict(sub=current_user.email))
return {"access_token": access_token, "token_type": "bearer"}

View File

@@ -83,7 +83,7 @@ async def update_user(
if current_user.id == id or current_user.admin:
db.users.update(session, id, new_data.dict())
if current_user.id == id:
access_token = security.create_access_token(data=dict(sub=new_data.email), expires_delta=timedelta(hours=2))
access_token = security.create_access_token(data=dict(sub=new_data.email))
token = {"access_token": access_token, "token_type": "bearer"}
return SnackResponse.success("User Updated", token)