mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 19:17:56 -05:00
refac
This commit is contained in:
1 parent
9a669197c8
commit
84d0940da1
6 files changed
+39
-8
No files matched your search
@@ -407,6 +407,36 @@ export const userSignOut = async () => {
|
||||
return res;
|
||||
};
|
||||
|
||||
export const getLogoutRedirectUrl = (redirectUrl?: string | null) => {
|
||||
const logoutUrl = new URL('/auth?state=logout', window.location.origin);
|
||||
const postLogoutUrl = new URL('/auth', window.location.origin);
|
||||
if (!redirectUrl) {
|
||||
return logoutUrl.href;
|
||||
}
|
||||
|
||||
const url = new URL(redirectUrl, window.location.origin);
|
||||
if (url.origin === window.location.origin && url.pathname === '/auth') {
|
||||
url.searchParams.set('state', 'logout');
|
||||
return url.href;
|
||||
}
|
||||
|
||||
const postLogoutRedirectUri = url.searchParams.get('post_logout_redirect_uri');
|
||||
if (postLogoutRedirectUri) {
|
||||
const configuredPostLogoutUrl = new URL(postLogoutRedirectUri, window.location.origin);
|
||||
if (
|
||||
configuredPostLogoutUrl.origin === window.location.origin &&
|
||||
configuredPostLogoutUrl.pathname === '/auth'
|
||||
) {
|
||||
url.searchParams.set('state', 'logout');
|
||||
}
|
||||
return url.href;
|
||||
}
|
||||
|
||||
url.searchParams.set('post_logout_redirect_uri', postLogoutUrl.href);
|
||||
url.searchParams.set('state', 'logout');
|
||||
return url.href;
|
||||
};
|
||||
|
||||
export const addUser = async (
|
||||
token: string,
|
||||
name: string,
|
||||
|
||||
Reference in new issue
Block a user