Skip to content

Commit

Permalink
fix: Manage OAuth2 state
Browse files Browse the repository at this point in the history
  • Loading branch information
taorepoara committed Oct 31, 2023
1 parent aae484a commit 29a2a12
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/oauth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class LenraOAuth2Client {
client: OAuth2Client;
popup?: OAuthPopup;
opts: LenraOAuth2Opts;
private state: string = (Math.random() + 1).toString(36).substring(2);


constructor(
Expand All @@ -38,6 +39,7 @@ export default class LenraOAuth2Client {
redirectUri: this.opts.redirectUri,
codeVerifier,
scope: this.opts.scopes,
state: this.state,
});

this.popup = new OAuthPopup(authUrl);
Expand All @@ -47,6 +49,7 @@ export default class LenraOAuth2Client {
{
redirectUri: this.opts.redirectUri,
codeVerifier,
state: this.state,
}
);
sessionStorage.setItem("access_token", token.accessToken);
Expand Down

0 comments on commit 29a2a12

Please sign in to comment.