8000 fix(authentication-oauth): Properly handle all oAuth errors by daffl · Pull Request #3284 · 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

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