E5E6 fix(authentication-oauth): Move Grant error handling to the correct spot by daffl · Pull Request #3297 · feathersjs/feathers · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

10BC0
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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