Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return args.credentials.map(async input => {
// Validate `id`.
if (!validateIdFormat(input.id)) {
throw new ValidationError("The provided `id` is an invalid ID.");
}
const tx = await pool.connect();
try {
await tx.query("BEGIN DEFERRABLE");
const before = await Credential.read(tx, input.id, credentialMap, {
forUpdate: true
});
if (!(before instanceof EmailCredential)) {
throw new NotFoundError("No email credential exists with this ID.");
}
if (!(await before.isAccessibleBy(realm, a, tx, "write.basic"))) {
throw new ForbiddenError(
"You do not have permission to update this credential."
);
}
const credential = await EmailCredential.write(
tx,
{
return args.credentials.map(async input => {
// Validate `id`.
if (!validateIdFormat(input.id)) {
throw new ValidationError("The provided `id` is an invalid ID.");
}
const tx = await pool.connect();
try {
await tx.query("BEGIN DEFERRABLE");
const before = await Credential.read(tx, input.id, credentialMap, {
forUpdate: true
});
if (!(before instanceof PasswordCredential)) {
throw new NotFoundError(
"The authority uses a strategy other than password."
);
}
if (!(await before.isAccessibleBy(realm, a, tx, "write.basic"))) {
throw new ForbiddenError(
"You do not have permission to update this credential."
);
}
if (
return args.credentials.map(async input => {
// Validate `id`.
if (!validateIdFormat(input.id)) {
throw new ValidationError("The provided `id` is an invalid ID.");
}
const tx = await pool.connect();
try {
await tx.query("BEGIN DEFERRABLE");
const before = await Credential.read(tx, input.id, credentialMap, {
forUpdate: true
});
if (!(before instanceof OpenIdCredential)) {
throw new NotFoundError("No openid credential exists with this ID.");
}
if (!(await before.isAccessibleBy(realm, a, tx, "write.basic"))) {
throw new ForbiddenError(
"You do not have permission to update this credential."
);
}
const credential = await OpenIdCredential.write(
tx,
{