Fixed UserController errors
This commit is contained in:
@@ -78,7 +78,7 @@ export class RoleController {
|
||||
});
|
||||
throw new PermissionsVerificationError(
|
||||
`Unable to verify permissions for role '${this.title}, it is recommended that you override and rewrite these permissions immediately.`,
|
||||
(err as Error).message
|
||||
(err as Error).message,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -248,14 +248,14 @@ export class RoleController {
|
||||
title: string;
|
||||
moniker: string;
|
||||
permissions: string[];
|
||||
}>
|
||||
}>,
|
||||
) {
|
||||
const schema = z
|
||||
.object({
|
||||
title: z.string().min(1, "Title cannot be empty."),
|
||||
moniker: z.string().min(1, "Moniker cannot be empty."),
|
||||
permissions: z.array(
|
||||
z.string().min(1, "Permission node cannot be empty")
|
||||
z.string().min(1, "Permission node cannot be empty"),
|
||||
),
|
||||
})
|
||||
.partial()
|
||||
@@ -271,7 +271,7 @@ export class RoleController {
|
||||
if (checkMoniker)
|
||||
throw new RoleError(
|
||||
"Moniker is already taken.",
|
||||
"Another role with this moniker already exists in the databse."
|
||||
"Another role with this moniker already exists in the databse.",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,16 +141,22 @@ export default class UserController {
|
||||
},
|
||||
});
|
||||
|
||||
const implicitPermissions = Object.keys(resources ?? {})
|
||||
.filter((v) => resources![v].length > 0)
|
||||
const resourceKeys: string[] = Object.keys(resources ?? {}) as string[];
|
||||
|
||||
const implicitPermissions = resources
|
||||
? resourceKeys
|
||||
// @ts-ignore
|
||||
.filter((v) => resources[v].length > 0)
|
||||
.map(
|
||||
(v) =>
|
||||
//@ts-ignore
|
||||
`resource.${v}.[${(resources![v] as { id: string }[])
|
||||
.map((o) => o.id)
|
||||
.join(",")}].user.${this.id}.implicit`,
|
||||
);
|
||||
)
|
||||
: [];
|
||||
|
||||
console.log(implicitPermissions);
|
||||
// console.log(implicitPermissions);
|
||||
|
||||
let checks = [
|
||||
(await this.fetchRoles()).map((v) => v.checkPermission(permission)),
|
||||
|
||||
Reference in New Issue
Block a user