diff --git a/apps/wr/app/store/common/auth/index.tsx b/apps/wr/app/store/common/auth/index.tsx index 7eceacb39..7b647d5e7 100644 --- a/apps/wr/app/store/common/auth/index.tsx +++ b/apps/wr/app/store/common/auth/index.tsx @@ -1,5 +1,6 @@ import { fetchType, getFetchWithCount } from "@/components/lib/api"; import { getUserInfo } from "@common/components/api"; +import { getCookie } from "@common/components/lib"; import toast from "react-hot-toast"; export type authState = { @@ -10,6 +11,7 @@ export type authState = { mdfcnAuthrtYn: string; delAuthrtYn: string; laeSeCd: string; + myUUID?: string; }; }; @@ -23,14 +25,15 @@ export const authStateExport: authState = { mdfcnAuthrtYn: "Y", delAuthrtYn: "Y", laeSeCd: "", + myUUID:'' }, }; export type authActions = { getMenuAuthrts: (menuCd: number) => void; getLaeSeCdCheck: () => Promise; + getMyUUID: () => Promise; }; - export const authActionsExport: (set: any, get: any) => authActions = ( set: any, get: any @@ -83,5 +86,29 @@ export const authActionsExport: (set: any, get: any) => authActions = ( console.error("laeSeCd check error", e); } }, + + getMyUUID: async () => { + try{ + const cached = get().auth.myUUID; + if (cached && cached !== "") { + return cached; + } + const tokenId = getCookie("token-id"); + + set((state: authState) => ({ + ...state, + auth: { + ...state.auth, + myUUID: tokenId, + }, + })); + + return tokenId; + }catch(e){ + console.error("getMyUUID error", e); + return undefined; + } + + }, }; };