This commit is contained in:
Timothy Jaeryang Baek committed 2026-08-31 00:11:04 -04:00
1 parent 9a669197c8
commit 84d0940da1
6 files changed
+39 -8

No files matched your search

+30
View File
@@ -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,