last update
This commit is contained in:
+2
-15
@@ -1,28 +1,15 @@
|
||||
import { AbilityBuilder, createMongoAbility } from "@casl/ability";
|
||||
import axios from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
const token = Cookies.get("access_token");
|
||||
|
||||
export function defineAbilitiesFor(user) {
|
||||
const { can, cannot, build } = new AbilityBuilder(createMongoAbility);
|
||||
|
||||
if (user) {
|
||||
can("access", "Dashboard");
|
||||
cannot("access", "Login");
|
||||
} else {
|
||||
// can("access", "Dashboard");
|
||||
can("access", "Login");
|
||||
cannot("access", "Dashboard");
|
||||
}
|
||||
|
||||
return build();
|
||||
}
|
||||
|
||||
export const fetchReq = async (url, headers) => {
|
||||
try {
|
||||
const response = await axios.get(url, headers);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("fetchReq error:", error.message);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user