From 4985e6574417c92c0f45ebc773912828f1cc8af6 Mon Sep 17 00:00:00 2001 From: faisolavolut Date: Thu, 6 Feb 2025 13:43:13 +0700 Subject: [PATCH] update user.ts --- helpers/user.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/helpers/user.ts b/helpers/user.ts index e97b83d..6435814 100644 --- a/helpers/user.ts +++ b/helpers/user.ts @@ -21,12 +21,22 @@ export const userToken = async () => { `${process.env.NEXT_PUBLIC_API_PORTAL}/api/users/me` ); const us = user.data.data; - console.log({ us }); if (us) { localStorage.setItem("user", JSON.stringify(user.data.data)); const roles = await userRoleMe(); } - } catch (e) {} - } catch (ex) {} + } catch (e) { + 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"); + } + } } };