Attached Files | 44490_20Q1_mobilecore.diff [^] (15,239 bytes) 2020-12-17 03:32 [Show Content] [Hide Content]diff --git a/web/org.openbravo.mobile.core/source/component/dialog/ob-profile.js b/web/org.openbravo.mobile.core/source/component/dialog/ob-profile.js
index 78d959cd..4321b249 100644
--- a/web/org.openbravo.mobile.core/source/component/dialog/ob-profile.js
+++ b/web/org.openbravo.mobile.core/source/component/dialog/ob-profile.js
@@ -315,9 +315,6 @@ enyo.kind({
success: function(inSender, inResponse) {
OB.DS.allowRequests(true);
if (inResponse.result === 'success') {
- // force new tokens at the reload
- OB.UTIL.localStorage.removeItem('authenticationClient');
- OB.UTIL.localStorage.removeItem('authenticationToken');
OB.UTIL.localStorage.removeItem(
'cacheAvailableForUser:' + OB.MobileApp.model.get('orgUserId')
);
diff --git a/web/org.openbravo.mobile.core/source/data/ob-requestrouter.js b/web/org.openbravo.mobile.core/source/data/ob-requestrouter.js
index cf30ddb7..b0d956f1 100644
--- a/web/org.openbravo.mobile.core/source/data/ob-requestrouter.js
+++ b/web/org.openbravo.mobile.core/source/data/ob-requestrouter.js
@@ -173,19 +173,6 @@
ajaxRequest.success = function(inSender, inResponse) {
var callback = function() {
- if (
- inResponse.authenticationClient &&
- inResponse.authenticationToken
- ) {
- OB.UTIL.localStorage.setItem(
- 'authenticationClient',
- encodeURIComponent(inResponse.authenticationClient)
- );
- OB.UTIL.localStorage.setItem(
- 'authenticationToken',
- encodeURIComponent(inResponse.authenticationToken)
- );
- }
if (!ajaxRequest.done) {
ajaxRequest.done = true;
if (ajaxRequest.origSuccess) {
@@ -358,25 +345,6 @@
data: updatedMessageData,
success: function(inSender, inResponse) {
var callback = function() {
- // get some authentication stuff
- if (
- inResponse.authenticationClient &&
- inResponse.authenticationToken
- ) {
- OB.UTIL.localStorage.setItem(
- 'authenticationClient',
- encodeURIComponent(
- JSON.stringify(inResponse.authenticationClient)
- )
- );
- OB.UTIL.localStorage.setItem(
- 'authenticationToken',
- encodeURIComponent(
- JSON.stringify(inResponse.authenticationToken)
- )
- );
- }
-
// message was successfull, remove it
OB.Dal.remove(
message,
@@ -806,19 +774,6 @@
}
ajaxRequest.success = function(inSender, inResponse) {
var callback = function() {
- if (
- inResponse.authenticationClient &&
- inResponse.authenticationToken
- ) {
- OB.UTIL.localStorage.setItem(
- 'authenticationClient',
- encodeURIComponent(inResponse.authenticationClient)
- );
- OB.UTIL.localStorage.setItem(
- 'authenticationToken',
- encodeURIComponent(inResponse.authenticationToken)
- );
- }
if (!ajaxRequest.done) {
ajaxRequest.done = true;
if (ajaxRequest.origSuccess) {
@@ -1031,26 +986,92 @@
'nextTimeToGoOnline',
OB.DEC.add(new Date().getTime(), intervalTime)
);
- var ajaxRequest = new enyo.Ajax({
- url: '../../org.openbravo.mobile.core.checkServerAvailability',
- cacheBust: false,
- method: 'GET',
- handleAs: 'json',
- timeout: OB.UTIL.localStorage.getItem('timeoutToGoOnline') || 5000,
- data: {
- params: JSON.stringify(params)
- },
- contentType: 'application/json;charset=utf-8',
- success: function(inSender, inResponse) {
- if (!this.done) {
- this.done = true;
- if (!inResponse || !inResponse.response) {
- return;
+ var getAjaxRequest = function() {
+ return new enyo.Ajax({
+ url: '../../org.openbravo.mobile.core.checkServerAvailability',
+ cacheBust: false,
+ method: 'GET',
+ handleAs: 'json',
+ timeout: OB.UTIL.localStorage.getItem('timeoutToGoOnline') || 5000,
+ data: {
+ params: JSON.stringify(params)
+ },
+ contentType: 'application/json;charset=utf-8',
+ success: function(inSender, inResponse) {
+ if (!this.done) {
+ this.done = true;
+ if (!inResponse || !inResponse.response) {
+ return;
+ }
+ if (inResponse.response.error) {
+ OB.info(
+ '[ConnectionStatus] Reconnect attempt failed. Server replied: ' +
+ inResponse.response.error
+ );
+ if (
+ parseInt(
+ OB.UTIL.localStorage.getItem('nextTimeToGoOnline'),
+ 10
+ ) <= new Date().getTime()
+ ) {
+ me.shouldTransitionToOnline(level >= 3 ? level : level + 1);
+ }
+ } else {
+ requestValidationCounter--;
+ if (
+ parseInt(
+ OB.UTIL.localStorage.getItem('nextTimeToGoOnline'),
+ 10
+ ) <= new Date().getTime()
+ ) {
+ if (
+ requestValidationCounter === 0 &&
+ !OB.MobileApp.model.isKeepWorking()
+ ) {
+ OB.info('[ConnectionStatus] Go to Online');
+ OB.MobileApp.model.triggerOnLine();
+ clearInterval(me.reconnect);
+ me.clearMaxAllowedTimeInOfflineTimeout();
+ OB.UTIL.localStorage.setItem(
+ 'lastTransitionToOnline',
+ new Date().getTime()
+ );
+ OB.UTIL.localStorage.setItem(
+ 'transitionsToOnline',
+ OB.UTIL.localStorage.getItem('transitionsToOnline')
+ ? OB.DEC.add(
+ parseInt(
+ OB.UTIL.localStorage.getItem(
+ 'transitionsToOnline'
+ ),
+ 10
+ ),
+ 1
+ )
+ : 1
+ );
+ setTimeout(function() {
+ OB.RR.ServTypeTransaction.sendMessages();
+ }, 10000);
+ } else {
+ if (level === 0 || level >= 3) {
+ OB.MobileApp.view.$.dialogsContainer.$.loginAgainDialog.show();
+ }
+ me.shouldTransitionToOnline(level >= 3 ? level : level + 1);
+ }
+ }
+ }
}
- if (inResponse.response.error) {
+ },
+ fail: function(inSender, inResponse) {
+ if (!this.done) {
+ this.done = true;
+ if (OB.MobileApp.model.get('currentWindow') === 'login') {
+ clearInterval(me.reconnect);
+ return true;
+ }
OB.info(
- '[ConnectionStatus] Reconnect attempt failed. Server replied: ' +
- inResponse.response.error
+ '[ConnectionStatus] Reconnect attempt failed, keep trying to reconnect'
);
if (
parseInt(
@@ -1060,74 +1081,15 @@
) {
me.shouldTransitionToOnline(level >= 3 ? level : level + 1);
}
- } else {
- requestValidationCounter--;
- if (
- parseInt(
- OB.UTIL.localStorage.getItem('nextTimeToGoOnline'),
- 10
- ) <= new Date().getTime()
- ) {
- if (
- requestValidationCounter === 0 &&
- !OB.MobileApp.model.isKeepWorking()
- ) {
- OB.info('[ConnectionStatus] Go to Online');
- OB.MobileApp.model.triggerOnLine();
- clearInterval(me.reconnect);
- me.clearMaxAllowedTimeInOfflineTimeout();
- OB.UTIL.localStorage.setItem(
- 'lastTransitionToOnline',
- new Date().getTime()
- );
- OB.UTIL.localStorage.setItem(
- 'transitionsToOnline',
- OB.UTIL.localStorage.getItem('transitionsToOnline')
- ? OB.DEC.add(
- parseInt(
- OB.UTIL.localStorage.getItem('transitionsToOnline'),
- 10
- ),
- 1
- )
- : 1
- );
- setTimeout(function() {
- OB.RR.ServTypeTransaction.sendMessages();
- }, 10000);
- } else {
- if (level === 0 || level >= 3) {
- OB.MobileApp.view.$.dialogsContainer.$.loginAgainDialog.show();
- }
- me.shouldTransitionToOnline(level >= 3 ? level : level + 1);
- }
- }
- }
- }
- },
- fail: function(inSender, inResponse) {
- if (!this.done) {
- this.done = true;
- OB.info(
- '[ConnectionStatus] Reconnect attempt failed, keep trying to reconnect'
- );
- if (
- parseInt(
- OB.UTIL.localStorage.getItem('nextTimeToGoOnline'),
- 10
- ) <= new Date().getTime() &&
- OB.MobileApp.model.get('currentWindow') !== 'login'
- ) {
- me.shouldTransitionToOnline(level >= 3 ? level : level + 1);
}
}
- }
- });
+ });
+ };
clearInterval(me.reconnect);
setTimeout(function() {
me.reconnect = setInterval(function() {
requestValidationCounter++;
- OB.RR.RequestRouter.execAjax(ajaxRequest, true);
+ OB.RR.RequestRouter.execAjax(getAjaxRequest(), true);
}, checkingIntervalTime / retries);
}, intervalTime - checkingIntervalTime);
},
@@ -1424,14 +1386,6 @@
'offlinePingInterval',
getPreference('OBMOBC_RequestRouterPingTime', 60000, 60000)
);
- OB.UTIL.localStorage.setItem(
- 'tokenRefreshInterval',
- getPreference(
- 'OBMOBC_RequestRouterTokenRefreshInterval',
- 10 * 60000,
- 30 * 60000
- )
- );
OB.UTIL.localStorage.setItem(
'maxNumOfRequestRetries',
getPreference('OBMOBC_NumberOfRequestRetries', 0, 0)
@@ -1476,53 +1430,6 @@
}
}, OB.UTIL.localStorage.getItem('offlinePingInterval'));
}
-
- if (this.refreshTokenProcess) {
- clearInterval(this.refreshTokenInterval);
- }
- this.countRefreshTokenErrors = 0;
- this.refreshTokenInterval = setInterval(function() {
- me.refreshToken();
- }, OB.UTIL.localStorage.getItem('tokenRefreshInterval'));
- },
-
- refreshToken: function() {
- var me = this;
- new OB.DS.Request('org.openbravo.mobile.core.authenticate.GetToken').exec(
- {
- ignoreForConnectionStatus: true
- },
- function(data) {
- if (data.authenticationClient && data.authenticationToken) {
- me.countRefreshTokenErrors = 0;
- OB.UTIL.localStorage.setItem(
- 'authenticationClient',
- encodeURIComponent(data.authenticationClient)
- );
- OB.UTIL.localStorage.setItem(
- 'authenticationToken',
- encodeURIComponent(data.authenticationToken)
- );
- } else {
- me.countRefreshTokenErrors++;
- }
- // too many errors, stop trying
- if (me.countRefreshTokenErrors > 3) {
- me.countRefreshTokenErrors = 0;
- clearInterval(me.refreshTokenInterval);
- }
- },
- function() {
- me.countRefreshTokenErrors++;
- // too many errors, stop trying
- if (me.countRefreshTokenErrors > 3) {
- me.countRefreshTokenErrors = 0;
- clearInterval(me.refreshTokenInterval);
- }
- },
- true,
- 20000
- );
},
isTransactionalService: function(serviceName) {
diff --git a/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js b/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js
index 0601fc6b..b3cee022 100644
--- a/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js
+++ b/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js
@@ -3401,9 +3401,6 @@ OB.Model.Terminal = Backbone.Model.extend({
function callback() {
OB.UTIL.showLoggingOut(true);
- OB.UTIL.localStorage.removeItem('authenticationClient');
- OB.UTIL.localStorage.removeItem('authenticationToken');
-
var rr,
ajaxRequest = new enyo.Ajax({
url: '../../org.openbravo.mobile.core.logout',
@@ -3438,9 +3435,6 @@ OB.Model.Terminal = Backbone.Model.extend({
);
}
- OB.UTIL.localStorage.removeItem('authenticationClient');
- OB.UTIL.localStorage.removeItem('authenticationToken');
-
var rr,
ajaxRequest = new enyo.Ajax({
url: '../../org.openbravo.mobile.core.logout',
diff --git a/web/org.openbravo.mobile.core/source/utils/ob-utilities.js b/web/org.openbravo.mobile.core/source/utils/ob-utilities.js
index a2eac3b0..76bd13a1 100644
--- a/web/org.openbravo.mobile.core/source/utils/ob-utilities.js
+++ b/web/org.openbravo.mobile.core/source/utils/ob-utilities.js
@@ -1758,22 +1758,6 @@
server = _.filter(servers.models, function(srv) {
return serverName === srv.get('name');
})[0];
- if (
- OB.UTIL.localStorage.getItem('authenticationClient') &&
- OB.UTIL.localStorage.getItem('authenticationToken')
- ) {
- if (serviceUrl.indexOf('?') === -1) {
- serviceUrl = serviceUrl + '?';
- } else {
- serviceUrl = serviceUrl + '&';
- }
- serviceUrl =
- serviceUrl +
- 'authenticationClient=' +
- OB.UTIL.localStorage.getItem('authenticationClient') +
- '&authenticationToken=' +
- OB.UTIL.localStorage.getItem('authenticationToken');
- }
if (!serviceUrl.startsWith('../../')) {
serviceUrl = '../../' + serviceUrl;
}
|