feat: redirect to same url on login/logout
This commit is contained in:
@ -29,7 +29,13 @@ export const menus: Record<string, Menu> = {
|
||||
title: "Login",
|
||||
icon: "IconLogin",
|
||||
cb: () => {
|
||||
window.location.pathname = "/api/auth/login";
|
||||
const url = new URL(window.location.href);
|
||||
url.pathname = "/api/auth/login";
|
||||
url.searchParams.set(
|
||||
"redirect",
|
||||
encodeURIComponent(window.location.pathname),
|
||||
);
|
||||
window.location.href = url.href;
|
||||
},
|
||||
visible: () => {
|
||||
return !getCookie("session_cookie");
|
||||
@ -49,7 +55,13 @@ export const menus: Record<string, Menu> = {
|
||||
title: "Logout",
|
||||
icon: "IconLogout",
|
||||
cb: () => {
|
||||
window.location.pathname = "/api/auth/logout";
|
||||
const url = new URL(window.location.href);
|
||||
url.pathname = "/api/auth/logout";
|
||||
url.searchParams.set(
|
||||
"redirect",
|
||||
encodeURIComponent(window.location.pathname),
|
||||
);
|
||||
window.location.href = url.href;
|
||||
},
|
||||
visible: () => {
|
||||
return !!getCookie("session_cookie");
|
||||
|
Reference in New Issue
Block a user