install and handle casle & prevent page dashboard & handle register and code verfication & get data in clinics page

This commit is contained in:
Ehsan
2025-05-27 03:40:06 +03:30
parent a9f98aea3b
commit d95815d4aa
27 changed files with 336 additions and 206 deletions
+16
View File
@@ -0,0 +1,16 @@
import { AbilityBuilder, createMongoAbility } from "@casl/ability";
export function defineAbilitiesFor(user) {
const { can, cannot, build } = new AbilityBuilder(createMongoAbility);
if (user?.role === "admin") {
can("access", "Dashboard");
} else if (user?.role === "manager") {
can("access", "Dashboard");
} else {
can("access", "Dashboard");
// cannot("access", "Dashboard");
}
return build();
}
+8
View File
@@ -0,0 +1,8 @@
import { cookies } from "next/headers";
export async function getUser() {
const cookieStore = cookies();
const raw = cookieStore.get("user");
if (!raw) return null;
return JSON.parse(raw.value);
}