notification added in with subs :D
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
import { adminClient } from "better-auth/client/plugins";
|
||||
import { createAuthClient } from "better-auth/react";
|
||||
import { ac, admin, systemAdmin, user } from "./auth-permissions";
|
||||
|
||||
export const authClient = createAuthClient({
|
||||
baseURL: `${window.location.origin}/lst/api/auth`,
|
||||
plugins: [adminClient()],
|
||||
plugins: [
|
||||
adminClient({
|
||||
ac,
|
||||
roles: {
|
||||
admin,
|
||||
user,
|
||||
systemAdmin,
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
export const { useSession, signUp, signIn, signOut } = authClient;
|
||||
|
||||
21
frontend/src/lib/auth-permissions.ts
Normal file
21
frontend/src/lib/auth-permissions.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { createAccessControl } from "better-auth/plugins/access";
|
||||
|
||||
export const statement = {
|
||||
project: ["create", "share", "update", "delete"],
|
||||
user: ["ban"],
|
||||
} as const;
|
||||
|
||||
export const ac = createAccessControl(statement);
|
||||
|
||||
export const user = ac.newRole({
|
||||
project: ["create"],
|
||||
});
|
||||
|
||||
export const admin = ac.newRole({
|
||||
project: ["create", "update"],
|
||||
});
|
||||
|
||||
export const systemAdmin = ac.newRole({
|
||||
project: ["create", "update", "delete"],
|
||||
user: ["ban"],
|
||||
});
|
||||
Reference in New Issue
Block a user