Skip to content

Commit

Permalink
fix(authentication-oauth): Properly handle all oAuth errors (#3284)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl authored Sep 27, 2023
1 parent ef9ee9d commit 148a9a3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/authentication-oauth/src/service.ts
Original file line number Diff line number Diff line change
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 @@ -114,12 +114,17 @@ export class OAuthService {
query,
redirect
}

const payload = grant?.response || result?.session?.response || result?.state?.response || params.query
const authentication = {
strategy: name,
...payload
}

if (payload.error) {
throw new OAuthError(payload.error_description || payload.error, payload)
}

try {
debug(`Calling ${authService}.create authentication with strategy ${name}`)

Expand Down

0 comments on commit 148a9a3

Please sign in to comment.