update user.ts
This commit is contained in:
parent
95f0ac2b7d
commit
4985e65744
|
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue