Skip to content

Commit

Permalink
fix(authentication-oauth): Move Grant error handling to the correct spot
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Oct 3, 2023
1 parent 8cd2f41 commit 8aefbe4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/authentication-oauth/src/service.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8aefbe4

Please sign in to comment.