fix: AggregateError thrown from ValidateSSOAccessTask
This commit is contained in:
@@ -19,17 +19,26 @@ export default class ValidateSSOAccessTask extends BaseTask<Props> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the validity of all the user's associated authentications.
|
try {
|
||||||
// @ts-expect-error TODO: Need to setup nested tsconfig with ES2021
|
// Check the validity of all the user's associated authentications.
|
||||||
const valid = await Promise.any(
|
// @ts-expect-error TODO: Need to setup nested tsconfig with ES2021
|
||||||
userAuthentications.map(async (authentication) =>
|
const valid = await Promise.any(
|
||||||
authentication.validateAccess({ transaction })
|
userAuthentications.map(async (authentication) =>
|
||||||
)
|
authentication.validateAccess({ transaction })
|
||||||
);
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// If any are valid then we're done here.
|
// If any are valid then we're done here.
|
||||||
if (valid) {
|
if (valid) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// Promise.any will throw an AggregateError if all validateAccess calls throw, this would
|
||||||
|
// only be the case if all receive an unexpected error. We want to throw the first error
|
||||||
|
// as a descriptive error message.
|
||||||
|
if ("errors" in err && err.errors.length > 0) {
|
||||||
|
throw err.errors[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If all are invalid then we need to revoke the users Outline sessions.
|
// If all are invalid then we need to revoke the users Outline sessions.
|
||||||
|
|||||||
Reference in New Issue
Block a user