로그인한 사용자의 uuid 찾기
This commit is contained in:
@@ -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<void>;
|
||||
getMyUUID: () => Promise<string |undefined>;
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user