Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createV2AuthXScope(
realm,
{
type: "authority",
authorityId: id
},
{
basic: "*",
details: "*"
}
)
];
// Add administration scopes.
for (const { roleId, scopes } of input.administration) {
const role = await Role.read(tx, roleId, { forUpdate: true });
if (
!role.isAccessibleBy(realm, a, tx, {
basic: "w",
scopes: "w",
users: ""
})
) {
throw new ForbiddenError(
`You do not have permission to modify the scopes of role ${roleId}.`
);
}
await Role.write(
tx,
{
createV2AuthXScope(
realm,
{
type: "authority",
authorityId: id
},
{
basic: "*",
details: "*"
}
)
];
// Add administration scopes.
for (const { roleId, scopes } of input.administration) {
const role = await Role.read(tx, roleId, { forUpdate: true });
if (
!role.isAccessibleBy(realm, a, tx, {
basic: "w",
scopes: "w",
users: ""
})
) {
throw new ForbiddenError(
`You do not have permission to modify the scopes of role ${roleId}.`
);
}
await Role.write(
tx,
{
{
type: "credential",
authorityId: credential.authorityId,
credentialId: id,
userId: credential.userId
},
{
basic: "*",
details: "*"
}
)
];
// Add administration scopes.
for (const { roleId, scopes } of input.administration) {
const role = await Role.read(tx, roleId, { forUpdate: true });
if (
!role.isAccessibleBy(realm, a, tx, {
basic: "w",
scopes: "w",
users: ""
})
) {
throw new ForbiddenError(
`You do not have permission to modify the scopes of role ${roleId}.`
);
}
await Role.write(
tx,
{
{
type: "credential",
authorityId: credential.authorityId,
credentialId: id,
userId: credential.userId
},
{
basic: "*",
details: "*"
}
)
];
// Add administration scopes.
for (const { roleId, scopes } of input.administration) {
const role = await Role.read(tx, roleId, { forUpdate: true });
if (
!role.isAccessibleBy(realm, a, tx, {
basic: "w",
scopes: "w",
users: ""
})
) {
throw new ForbiddenError(
`You do not have permission to modify the scopes of role ${roleId}.`
);
}
await Role.write(
tx,
{
{
type: "credential",
authorityId: credential.authorityId,
credentialId: id,
userId: credential.userId
},
{
basic: "*",
details: "*"
}
)
];
// Add administration scopes.
for (const { roleId, scopes } of input.administration) {
const role = await Role.read(tx, roleId, { forUpdate: true });
if (
!role.isAccessibleBy(realm, a, tx, {
basic: "w",
scopes: "w",
users: ""
})
) {
throw new ForbiddenError(
`You do not have permission to modify the scopes of role ${roleId}.`
);
}
await Role.write(
tx,
{
createV2AuthXScope(
realm,
{
type: "authority",
authorityId: id
},
{
basic: "*",
details: "*"
}
)
];
// Add administration scopes.
for (const { roleId, scopes } of input.administration) {
const role = await Role.read(tx, roleId, { forUpdate: true });
if (
!role.isAccessibleBy(realm, a, tx, {
basic: "w",
scopes: "w",
users: ""
})
) {
throw new ForbiddenError(
`You do not have permission to modify the scopes of role ${roleId}.`
);
}
await Role.write(
tx,
{
authority.details.assignsCreatedUsersToRoleIds.map(id =>
Role.read(tx, id)
)
public async assignsCreatedUsersToRoles(
tx: PoolClient,
refresh?: boolean
): Promise {
if (!refresh && this._assignsCreatedUsersToRoles) {
return this._assignsCreatedUsersToRoles;
}
if (!this.details.assignsCreatedUsersToRoleIds) {
return [];
}
return (this._assignsCreatedUsersToRoles = Role.read(
tx,
this.details.assignsCreatedUsersToRoleIds
));
}
}