mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: make edit course page private
This commit is contained in:
parent
46f13fac87
commit
8f8257b9e7
4 changed files with 28 additions and 32 deletions
|
|
@ -9,29 +9,6 @@ from fastapi.responses import JSONResponse
|
|||
|
||||
router = APIRouter()
|
||||
|
||||
# DEPRECATED
|
||||
@router.post("/token", response_model=Token)
|
||||
async def login_for_access_token(request: Request, form_data: OAuth2PasswordRequestForm = Depends()):
|
||||
"""
|
||||
OAuth2 compatible token login, get access token for future requests
|
||||
"""
|
||||
user = await authenticate_user(request, form_data.username, form_data.password)
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Incorrect Email or password",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
access_token_expires = timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
|
||||
access_token = create_access_token(
|
||||
data={"sub": user.username}, expires_delta=access_token_expires
|
||||
)
|
||||
|
||||
response = JSONResponse(content={"access_token" : access_token ,"token_type": "bearer"})
|
||||
response.set_cookie(key="user_token", value=access_token, httponly=True, expires=3600,secure=True)
|
||||
|
||||
return response
|
||||
|
||||
@router.post('/refresh')
|
||||
def refresh(Authorize: AuthJWT = Depends()):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue