Skip to content

Commit

Permalink
CS-4064: Refresh Token in IDM enabled Instance does not live more tha…
Browse files Browse the repository at this point in the history
…n 24 hours
  • Loading branch information
odukhnytskyi-sugarcrm committed Oct 30, 2024
1 parent cfbb253 commit 93e27c5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,16 @@ function SugarApi(args) {
error: onError
};

// prevents concurrent events from multiple tabs asking for a
// refresh token
if (!('crosstab' in window) || !crosstab.supported) {
console.log('------_handleErrorAndRefreshToken-------');
//console.log(localStorage.getItem('authInprogress'));
console.log('----------' + Date.now() + '----------');
// if (localStorage.getItem('authInprogress') === '1') {
// return;
// }
//localStorage.setItem('authInprogress', 1);
self.login(null, {refresh: true}, {
complete: refreshCallbacks.complete,
success: refreshCallbacks.success,
Expand All @@ -474,12 +483,21 @@ function SugarApi(args) {
var status = event.data;
switch (status) {
case 'success':
console.log('------_handleErrorAndRefreshToken-success------');
console.log('----------' + Date.now() + '----------');
//localStorage.setItem('authInprogress', 0);
refreshCallbacks.success();
break;
case 'error':
console.log('------_handleErrorAndRefreshToken-error------');
console.log('----------' + Date.now() + '----------');
//localStorage.setItem('authInprogress', 0);
refreshCallbacks.error();
break;
case 'complete':
console.log('------_handleErrorAndRefreshToken-complete------');
console.log('----------' + Date.now() + '----------');
//localStorage.setItem('authInprogress', 0);
refreshCallbacks.complete();
crosstab.off('auth:refresh:complete');
break;
Expand Down Expand Up @@ -2136,6 +2154,7 @@ module.exports = {
*/
createInstance: function(args) {
_instance = new SugarApi(args);
//localStorage.setItem('authInprogress', 0);

if (!('crosstab' in window) || !crosstab.supported) {
return _instance;
Expand All @@ -2148,6 +2167,9 @@ module.exports = {

// prevents concurrent events from multiple tabs asking for a
// refresh token
console.log('------createInstance-------');
console.log(this._runningRefreshToken);
console.log('----------' + Date.now() + '----------');
if (this._runningRefreshToken) {
return;
}
Expand Down

0 comments on commit 93e27c5

Please sign in to comment.