fix: dedent auth/me and auth/logout routes
Some checks are pending
Check Python Version Consistency / Check Python Version (push) Waiting to run
Some checks are pending
Check Python Version Consistency / Check Python Version (push) Waiting to run
This commit is contained in:
parent
d9a553a43b
commit
c45613982b
24
main.py
24
main.py
|
|
@ -133,19 +133,19 @@ async def auth(request: Request):
|
||||||
request.session['user'] = dict(user)
|
request.session['user'] = dict(user)
|
||||||
return RedirectResponse(url='/static/billing-dashboard.html')
|
return RedirectResponse(url='/static/billing-dashboard.html')
|
||||||
|
|
||||||
@app.get("/auth/me")
|
@app.get("/auth/me")
|
||||||
async def me(request: Request):
|
async def me(request: Request):
|
||||||
email = request.headers.get("x-goog-authenticated-user-email", "")
|
email = request.headers.get("x-goog-authenticated-user-email", "")
|
||||||
if not email:
|
if not email:
|
||||||
raise HTTPException(status_code=401, detail="Not authenticated")
|
raise HTTPException(status_code=401, detail="Not authenticated")
|
||||||
# IAP sender "accounts.google.com:chris@vauco.no" - vi fjerner prefix
|
# IAP sender "accounts.google.com:chris@vauco.no" - vi fjerner prefix
|
||||||
clean_email = email.split(":")[-1]
|
clean_email = email.split(":")[-1]
|
||||||
return JSONResponse({"email": clean_email, "authenticated": True})
|
return JSONResponse({"email": clean_email, "authenticated": True})
|
||||||
|
|
||||||
@app.get('/auth/logout')
|
@app.get('/auth/logout')
|
||||||
async def logout(request: Request):
|
async def logout(request: Request):
|
||||||
request.session.pop('user', None)
|
request.session.pop('user', None)
|
||||||
return RedirectResponse(url='/static/billing-dashboard.html')
|
return RedirectResponse(url='/static/billing-dashboard.html')
|
||||||
|
|
||||||
|
|
||||||
ALLOWED_EMAILS = [email.strip() for email in os.environ.get("ALLOWED_EMAILS", "").split(",") if email.strip()]
|
ALLOWED_EMAILS = [email.strip() for email in os.environ.get("ALLOWED_EMAILS", "").split(",") if email.strip()]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user