Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add local storage check against parallel calls to session-service #272

Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@schibsted/account-sdk-browser",
"version": "4.8.7-beta.4",
"version": "4.8.7-beta.5",
"description": "Schibsted account SDK for browsers",
"main": "index.js",
"type": "module",
Expand Down
8 changes: 8 additions & 0 deletions src/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export class Identity extends EventEmitter {
this.log = log;
this.callbackBeforeRedirect = callbackBeforeRedirect;
this._sessionDomain = sessionDomain;
this.cache.set("sessionFlowOngoing", false);

// Internal hack: set to false to always refresh from hassession
this._enableSessionCaching = true;
Expand Down Expand Up @@ -490,6 +491,12 @@ export class Identity extends EventEmitter {
* @return {Promise<HasSessionSuccessResponse|HasSessionFailureResponse>}
*/
hasSession() {
const checkIfSessionOngoing = this.cache.get("sessionFlowOngoing");
if (checkIfSessionOngoing)
{
return this._session;
}

if (this._hasSessionInProgress) {
return this._hasSessionInProgress;
}
Expand Down Expand Up @@ -533,6 +540,7 @@ export class Identity extends EventEmitter {
if (sessionData){
// for expiring session and safari browser do full page redirect to gain new session
if(_checkRedirectionNeed(sessionData)){
this.cache.set("sessionFlowOngoing", true);
await this.callbackBeforeRedirect();

return this._sessionService.makeUrl(sessionData.redirectURL);
Expand Down
2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Automatically generated in 'npm version' by scripts/genversion.js

'use strict'
const version = '4.8.7-beta.4';
const version = '4.8.7-beta.5';
export default version;
Loading