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