refactor(auth): added module and submodule access to the user
This commit is contained in:
@@ -19,12 +19,18 @@ export const useGetUserRoles = create<SettingState>()((set) => ({
|
||||
try {
|
||||
//const response = await axios.get<{data: Setting[]}>(`${process.env.NEXT_PUBLIC_URL}/api/settings/client`);
|
||||
const token = localStorage.getItem("auth_token");
|
||||
const response = await axios.get("/api/auth/getuseraccess", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const data: FetchModulesResponse = response.data; //await response.json();
|
||||
//console.log(data);
|
||||
set({ userRoles: data.data });
|
||||
if (token) {
|
||||
const response = await axios.get("/api/auth/getuseraccess", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const data: FetchModulesResponse = response.data; //await response.json();
|
||||
|
||||
//console.log(data);
|
||||
set({ userRoles: data.data });
|
||||
} else {
|
||||
//console.log(data);
|
||||
set({ userRoles: [] });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch settings:", error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user