fix: Improve error handling for Azure-specific errors not captured in OAuth2 strategy
This commit is contained in:
@@ -24,6 +24,17 @@ export default function createMiddleware(providerName: string) {
|
||||
return ctx.redirect(`/?notice=auth-error`);
|
||||
}
|
||||
|
||||
// Handle errors from Azure which come in the format: message, Trace ID,
|
||||
// Correlation ID, Timestamp in these two query string parameters.
|
||||
const { error, error_description } = ctx.request.query;
|
||||
if (error && error_description) {
|
||||
console.error(error_description);
|
||||
|
||||
// Display only the descriptive message to the user, log the rest
|
||||
const description = error_description.split("Trace ID")[0];
|
||||
return ctx.redirect(`/?notice=auth-error&description=${description}`);
|
||||
}
|
||||
|
||||
if (result.user.isSuspended) {
|
||||
return ctx.redirect("/?notice=suspended");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user