Skip to content

Commit 148a9a3

Browse files
authored
fix(authentication-oauth): Properly handle all oAuth errors (#3284)
1 parent ef9ee9d commit 148a9a3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/authentication-oauth/src/service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class OAuthError extends FeathersError {
2828
constructor(
2929
message: string,
3030
data: any,
31-
public location: string
31+
public location?: string
3232
) {
3333
super(message, 'NotAuthenticated', 401, 'not-authenticated', data)
3434
}
@@ -114,12 +114,17 @@ export class OAuthService {
114114
query,
115115
redirect
116116
}
117+
117118
const payload = grant?.response || result?.session?.response || result?.state?.response || params.query
118119
const authentication = {
119120
strategy: name,
120121
...payload
121122
}
122123

124+
if (payload.error) {
125+
throw new OAuthError(payload.error_description || payload.error, payload)
126+
}
127+
123128
try {
124129
debug(`Calling ${authService}.create authentication with strategy ${name}`)
125130

0 commit comments

Comments
 (0)