Skip to content

Commit

Permalink
fix(web): code exchange returning success on invalid grant
Browse files Browse the repository at this point in the history
  • Loading branch information
zapteryx committed Dec 29, 2022
1 parent 2f8760b commit 7e158a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/events/web/exchange.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export type OAuth2Data = {
token_type: string;
access_token: string;
error?: string;
error_description?: string;
};
6 changes: 6 additions & 0 deletions src/events/web/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export default {
const oauthData = (await getJSONResponse(
tokenResponseData.body,
)) as OAuth2Data;
if (oauthData.error) {
return callback({
status: 'error-auth',
error: oauthData.error,
});
}
const encryptedToken = CryptoJS.AES.encrypt(
`${oauthData.token_type} ${oauthData.access_token}`,
settings.features.web.encryptionKey,
Expand Down

0 comments on commit 7e158a1

Please sign in to comment.