feat: add userConfig claims

This commit is contained in:
2025-08-04 14:32:20 +05:30
parent e4817ffdf7
commit 083f65639d
3 changed files with 12 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ export async function userConfigRoutes(fastify: FastifyInstance) {
fastify.get( fastify.get(
"/", "/",
{ {
config: { requiredClaims: ["config:read"] }, config: { requiredClaims: ["userConfig:read"] },
preHandler: [fastify.authorize], preHandler: [fastify.authorize],
}, },
getConfigHandler getConfigHandler
@@ -18,7 +18,7 @@ export async function userConfigRoutes(fastify: FastifyInstance) {
schema: { schema: {
body: $userConfig("updateUserConfigInput"), body: $userConfig("updateUserConfigInput"),
}, },
config: { requiredClaims: ["config:write"] }, config: { requiredClaims: ["userConfig:write"] },
preHandler: [fastify.authorize], preHandler: [fastify.authorize],
}, },
updateConfigHandler updateConfigHandler

View File

@@ -28,6 +28,8 @@ export type Claim =
| "notification:delete" | "notification:delete"
| "config:read" | "config:read"
| "config:write" | "config:write"
| "userConfig:read"
| "userConfig:write"
| "mail:all" | "mail:all"
| "view:read" | "view:read"
| "view:write" | "view:write"

View File

@@ -29,6 +29,8 @@ export const rules: Record<
"notification:delete", "notification:delete",
"config:read", "config:read",
"config:write", "config:write",
"userConfig:read",
"userConfig:write",
"mail:all", "mail:all",
"view:read", "view:read",
"view:write", "view:write",
@@ -70,6 +72,8 @@ export const rules: Record<
"notification:delete", "notification:delete",
"config:read", "config:read",
"config:write", "config:write",
"userConfig:read",
"userConfig:write",
"mail:all", "mail:all",
"view:read", "view:read",
"view:write", "view:write",
@@ -104,6 +108,8 @@ export const rules: Record<
"notification:read", "notification:read",
"notification:delete", "notification:delete",
"config:read", "config:read",
"userConfig:read",
"userConfig:write",
"mail:all", "mail:all",
"view:read", "view:read",
"view:write", "view:write",
@@ -146,6 +152,8 @@ export const rules: Record<
"payment:read", "payment:read",
"alert:read", "alert:read",
"alert:write", "alert:write",
"userConfig:read",
"userConfig:write",
], ],
hiddenFields: { hiddenFields: {
orgs: ["__v"], orgs: ["__v"],