mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-16 12:15:56 +08:00
refac/fix: signout redirect flow
This commit is contained in:
parent
fcb93f3155
commit
7df6d7f325
@ -31,7 +31,7 @@ from open_webui.env import (
|
||||
SRC_LOG_LEVELS,
|
||||
)
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||
from fastapi.responses import RedirectResponse, Response
|
||||
from fastapi.responses import RedirectResponse, Response, JSONResponse
|
||||
from open_webui.config import OPENID_PROVIDER_URL, ENABLE_OAUTH_SIGNUP, ENABLE_LDAP
|
||||
from pydantic import BaseModel
|
||||
|
||||
@ -577,9 +577,14 @@ async def signout(request: Request, response: Response):
|
||||
logout_url = openid_data.get("end_session_endpoint")
|
||||
if logout_url:
|
||||
response.delete_cookie("oauth_id_token")
|
||||
return RedirectResponse(
|
||||
|
||||
return JSONResponse(
|
||||
status_code=200,
|
||||
content={
|
||||
"status": True,
|
||||
"redirect_url": f"{logout_url}?id_token_hint={oauth_id_token}",
|
||||
},
|
||||
headers=response.headers,
|
||||
url=f"{logout_url}?id_token_hint={oauth_id_token}",
|
||||
)
|
||||
else:
|
||||
raise HTTPException(
|
||||
@ -594,12 +599,18 @@ async def signout(request: Request, response: Response):
|
||||
)
|
||||
|
||||
if WEBUI_AUTH_SIGNOUT_REDIRECT_URL:
|
||||
return RedirectResponse(
|
||||
return JSONResponse(
|
||||
status_code=200,
|
||||
content={
|
||||
"status": True,
|
||||
"redirect_url": WEBUI_AUTH_SIGNOUT_REDIRECT_URL,
|
||||
},
|
||||
headers=response.headers,
|
||||
url=WEBUI_AUTH_SIGNOUT_REDIRECT_URL,
|
||||
)
|
||||
|
||||
return {"status": True}
|
||||
return JSONResponse(
|
||||
status_code=200, content={"status": True}, headers=response.headers
|
||||
)
|
||||
|
||||
|
||||
############################
|
||||
|
@ -347,6 +347,7 @@ export const userSignOut = async () => {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
export const addUser = async (
|
||||
|
@ -156,12 +156,11 @@
|
||||
<button
|
||||
class="flex rounded-md py-2 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition"
|
||||
on:click={async () => {
|
||||
await userSignOut();
|
||||
const res = await userSignOut();
|
||||
user.set(null);
|
||||
|
||||
localStorage.removeItem('token');
|
||||
location.href = '/auth';
|
||||
|
||||
location.href = res?.redirect_url ?? '/auth';
|
||||
show = false;
|
||||
}}
|
||||
>
|
||||
|
@ -464,11 +464,11 @@
|
||||
}
|
||||
|
||||
if (now >= exp) {
|
||||
await userSignOut();
|
||||
const res = await userSignOut();
|
||||
user.set(null);
|
||||
|
||||
localStorage.removeItem('token');
|
||||
location.href = '/auth';
|
||||
|
||||
location.href = res?.redirect_url ?? '/auth';
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user