mirror of
https://github.com/hexastack/hexabot
synced 2025-02-22 20:38:32 +00:00
Merge pull request #140 from Hexastack/139-bug-missing-id-with-logout-redirection
fix(frontend): logout redirection logic
This commit is contained in:
commit
4b074af1b2
@ -6,6 +6,7 @@
|
|||||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
|
|
||||||
@ -32,11 +33,12 @@ export const useAuth = () => {
|
|||||||
|
|
||||||
export const useLogoutRedirection = () => {
|
export const useLogoutRedirection = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const pathname = usePathname();
|
||||||
const hasPublicPath = PUBLIC_PATHS.includes(router.pathname);
|
const hasPublicPath = PUBLIC_PATHS.includes(router.pathname);
|
||||||
const logoutRedirection = async (fullReload: boolean = false) => {
|
const logoutRedirection = async (fullReload: boolean = false) => {
|
||||||
if (!hasPublicPath) {
|
if (!hasPublicPath) {
|
||||||
const redirectUrl = `/${RouterType.LOGIN}?redirect=${encodeURIComponent(
|
const redirectUrl = `/${RouterType.LOGIN}?redirect=${encodeURIComponent(
|
||||||
router.pathname,
|
pathname,
|
||||||
)}`;
|
)}`;
|
||||||
|
|
||||||
if (fullReload) {
|
if (fullReload) {
|
||||||
|
Loading…
Reference in New Issue
Block a user