Gregniuki commited on
Commit
ba5569f
1 Parent(s): b5d2082

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -290,15 +290,13 @@ async def register_post(
290
  # Store user info in the session after successful registration
291
  request.session["access_token"] = {"username": registered_user.username, "email": registered_user.email}
292
  # Create an access token
293
- access_token = create_access_token(data={"sub": registered_user.email})
294
  # Redirect to the protected route
295
  url = app.url_path_for("get_protected")
296
  response = RedirectResponse(url, status_code=status.HTTP_303_SEE_OTHER)
297
  response.set_cookie(key="access_token", value=f"Bearer {access_token}", httponly=True)
298
  return response
299
- # response = RedirectResponse(url="/protected")
300
- # response.set_cookie(key="access_token", value=f"Bearer {access_token}", httponly=True)
301
- # return response
302
  except HTTPException as e:
303
  return templates.TemplateResponse("register.html", {"request": request, "error_message": e.detail})
304
 
 
290
  # Store user info in the session after successful registration
291
  request.session["access_token"] = {"username": registered_user.username, "email": registered_user.email}
292
  # Create an access token
293
+ access_token = create_access_token(data={"sub": user.email}, expires_delta=timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES))
294
  # Redirect to the protected route
295
  url = app.url_path_for("get_protected")
296
  response = RedirectResponse(url, status_code=status.HTTP_303_SEE_OTHER)
297
  response.set_cookie(key="access_token", value=f"Bearer {access_token}", httponly=True)
298
  return response
299
+
 
 
300
  except HTTPException as e:
301
  return templates.TemplateResponse("register.html", {"request": request, "error_message": e.detail})
302