Wauplin HF Staff commited on
Commit
197023a
·
1 Parent(s): ccec886

fix redirect

Browse files
Files changed (1) hide show
  1. auth.py +3 -9
auth.py CHANGED
@@ -57,15 +57,9 @@ async def oauth_redirect_callback(request: Request):
57
 
58
 
59
  async def check_oauth(request: Request, call_next):
60
- if request.url.path in (
61
- "/",
62
- "/auth/huggingface",
63
- "/auth/callback",
64
- ): # not protected
65
- return await call_next(request)
66
- if request.session.get("user"): # authenticated
67
- return await call_next(request)
68
- return RedirectResponse("/")
69
 
70
 
71
  def get_app() -> FastAPI:
 
57
 
58
 
59
  async def check_oauth(request: Request, call_next):
60
+ if request.url.path.startswith("/gradio") and not request.session.get("user"): # protected route but not authenticated
61
+ return RedirectResponse("/")
62
+ return await call_next(request)
 
 
 
 
 
 
63
 
64
 
65
  def get_app() -> FastAPI: