From e9c0828937453c3f0a1bd16010089b825185eab6 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Tue, 3 Oct 2023 15:06:26 -0700 Subject: [PATCH] fix(authentication-oauth): Move Grant error handling to the correct spot (#3297) --- packages/authentication-oauth/src/service.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/authentication-oauth/src/service.ts b/packages/authentication-oauth/src/service.ts index 79a6da9448..c0f0c072b3 100644 --- a/packages/authentication-oauth/src/service.ts +++ b/packages/authentication-oauth/src/service.ts @@ -1,6 +1,6 @@ import { createDebug } from '@feathersjs/commons' import { HookContext, NextFunction, Params } from '@feathersjs/feathers' -import { FeathersError } from '@feathersjs/errors' +import { FeathersError, GeneralError } from '@feathersjs/errors' // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore import Grant from 'grant/lib/grant' @@ -28,7 +28,7 @@ export class OAuthError extends FeathersError { constructor( message: string, data: any, - public location?: string + public location: string ) { super(message, 'NotAuthenticated', 401, 'not-authenticated', data) } @@ -121,11 +121,11 @@ export class OAuthService { ...payload } - if (payload.error) { - throw new OAuthError(payload.error_description || payload.error, payload) - } - try { + if (payload.error) { + throw new GeneralError(payload.error_description || payload.error, payload) + } + debug(`Calling ${authService}.create authentication with strategy ${name}`) const authResult = await this.service.create(authentication, authParams)