mirror of
https://github.com/hexastack/hexabot
synced 2025-02-23 12:59:14 +00:00
fix: redirection to dynamic path
This commit is contained in:
parent
8089206df1
commit
77ac209bf8
@ -32,14 +32,12 @@ export const useAuth = () => {
|
|||||||
|
|
||||||
export const useLogoutRedirection = () => {
|
export const useLogoutRedirection = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const isDynamicPath = router.pathname.includes("[");
|
|
||||||
const hasPublicPath = PUBLIC_PATHS.includes(router.pathname);
|
const hasPublicPath = PUBLIC_PATHS.includes(router.pathname);
|
||||||
const encodedPath = isDynamicPath
|
|
||||||
? encodeURIComponent("/settings")
|
|
||||||
: encodeURIComponent(router.pathname);
|
|
||||||
const logoutRedirection = async (fullReload: boolean = false) => {
|
const logoutRedirection = async (fullReload: boolean = false) => {
|
||||||
if (!hasPublicPath) {
|
if (!hasPublicPath) {
|
||||||
const redirectUrl = `/${RouterType.LOGIN}?redirect=${encodedPath}`;
|
const redirectUrl = `/${RouterType.LOGIN}?redirect=${encodeURIComponent(
|
||||||
|
router.asPath,
|
||||||
|
)}`;
|
||||||
|
|
||||||
if (fullReload) {
|
if (fullReload) {
|
||||||
window.location.replace(redirectUrl);
|
window.location.replace(redirectUrl);
|
||||||
|
Loading…
Reference in New Issue
Block a user