update user.ts

This commit is contained in:
faisolavolut 2025-02-06 13:43:13 +07:00
parent 95f0ac2b7d
commit 4985e65744
1 changed files with 13 additions and 3 deletions

View File

@ -21,12 +21,22 @@ export const userToken = async () => {
`${process.env.NEXT_PUBLIC_API_PORTAL}/api/users/me` `${process.env.NEXT_PUBLIC_API_PORTAL}/api/users/me`
); );
const us = user.data.data; const us = user.data.data;
console.log({ us });
if (us) { if (us) {
localStorage.setItem("user", JSON.stringify(user.data.data)); localStorage.setItem("user", JSON.stringify(user.data.data));
const roles = await userRoleMe(); const roles = await userRoleMe();
} }
} catch (e) {} } catch (e) {
} catch (ex) {} throw new Error("Access Denied");
}
} catch (ex) {
try {
if (user) {
const w = window as any;
w.user = JSON.parse(user);
}
} catch (ex) {
throw new Error("Access Denied");
}
}
} }
}; };