Return more error messages (#14066)

This commit is contained in:
José Varela
2022-06-23 19:18:18 +01:00
committed by GitHub
parent 2b93e2203c
commit 4a75a2bcbc
2 changed files with 6 additions and 18 deletions

View File

@@ -5,11 +5,11 @@ import ms from 'ms';
import { Client, errors, generators, Issuer } from 'openid-client';
import { getAuthProvider } from '../../auth';
import env from '../../env';
import { BaseException } from '@directus/shared/exceptions';
import {
InvalidConfigException,
InvalidCredentialsException,
InvalidTokenException,
InvalidProviderException,
ServiceUnavailableException,
} from '../../exceptions';
import logger from '../../logger';
@@ -294,14 +294,8 @@ export function createOAuth2AuthRouter(providerName: string): Router {
if (redirect) {
let reason = 'UNKNOWN_EXCEPTION';
if (error instanceof ServiceUnavailableException) {
reason = 'SERVICE_UNAVAILABLE';
} else if (error instanceof InvalidCredentialsException) {
reason = 'INVALID_USER';
} else if (error instanceof InvalidTokenException) {
reason = 'INVALID_TOKEN';
} else if (error instanceof InvalidProviderException) {
reason = 'INVALID_PROVIDER';
if (error instanceof BaseException) {
reason = error.code;
} else {
logger.warn(error, `[OAuth2] Unexpected error during OAuth2 login`);
}

View File

@@ -5,11 +5,11 @@ import ms from 'ms';
import { Client, errors, generators, Issuer } from 'openid-client';
import { getAuthProvider } from '../../auth';
import env from '../../env';
import { BaseException } from '@directus/shared/exceptions';
import {
InvalidConfigException,
InvalidCredentialsException,
InvalidTokenException,
InvalidProviderException,
ServiceUnavailableException,
} from '../../exceptions';
import logger from '../../logger';
@@ -317,14 +317,8 @@ export function createOpenIDAuthRouter(providerName: string): Router {
if (redirect) {
let reason = 'UNKNOWN_EXCEPTION';
if (error instanceof ServiceUnavailableException) {
reason = 'SERVICE_UNAVAILABLE';
} else if (error instanceof InvalidCredentialsException) {
reason = 'INVALID_USER';
} else if (error instanceof InvalidTokenException) {
reason = 'INVALID_TOKEN';
} else if (error instanceof InvalidProviderException) {
reason = 'INVALID_PROVIDER';
if (error instanceof BaseException) {
reason = error.code;
} else {
logger.warn(error, `[OpenID] Unexpected error during OpenID login`);
}