From 11e9d2b043970742d8bb1263980ef23c23e408d0 Mon Sep 17 00:00:00 2001 From: ochan1 Date: Tue, 4 May 2021 03:07:24 -0700 Subject: [PATCH 1/4] Alias username fetch on CheckCredential calls --- src/cloud.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/cloud.js b/src/cloud.js index 3b3081604..d5626eaf8 100755 --- a/src/cloud.js +++ b/src/cloud.js @@ -282,13 +282,15 @@ Cloud.prototype.checkCredentials = function (onSuccess, onError, response) { if (user.username) { myself.username = user.username; myself.verified = user.verified; + myself.previous_username_admin = user.previous_username_admin; } if (onSuccess) { onSuccess.call( null, user.username, user.role, - response ? JSON.parse(response) : null + response ? JSON.parse(response) : null, + user.previous_username_admin ); } }, @@ -327,6 +329,34 @@ Cloud.prototype.logout = function (onSuccess, onError) { ); }; +Cloud.prototype.logoutAlias = function (onSuccess, onError) { + var myself = this; + this.getCurrentUser( + function (user) { + if (user.username && user.previous_username_admin) { + myself.login( + user.previous_username_admin, + 0, // password is irrelevant + false, // ignored + function (username, role, previous_username_admin, response) { + alert( + response.message, + function () { + onSuccess.call(); + sessionStorage.previous_username_admin = previous_username_admin; + sessionStorage.username = username; + sessionStorage.role = role; + } + ); + }, + onError + ); + } + }, + onError + ); +} + Cloud.prototype.login = function ( username, password, From da56559cbc7ffa3f7cab6b732c300f2af4df7b84 Mon Sep 17 00:00:00 2001 From: ochan1 Date: Thu, 1 Jul 2021 00:54:07 -0700 Subject: [PATCH 2/4] Empty string as ignored password + unused persistence boolean clarification --- src/cloud.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cloud.js b/src/cloud.js index d5626eaf8..b6b108040 100755 --- a/src/cloud.js +++ b/src/cloud.js @@ -336,9 +336,9 @@ Cloud.prototype.logoutAlias = function (onSuccess, onError) { if (user.username && user.previous_username_admin) { myself.login( user.previous_username_admin, - 0, // password is irrelevant - false, // ignored - function (username, role, previous_username_admin, response) { + '', // password is irrelevant, but can't be null + false, // ignored, will use the Admin's settings saved in the backend + function (username, role, response, previous_username_admin) { alert( response.message, function () { From 2f24db302ce79e07afc3c4de761a38267d43827d Mon Sep 17 00:00:00 2001 From: ochan1 Date: Thu, 1 Jul 2021 02:34:58 -0700 Subject: [PATCH 3/4] Move order of Cloud Login's Previous Username Admin param --- src/cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cloud.js b/src/cloud.js index b6b108040..8b01fcc3c 100755 --- a/src/cloud.js +++ b/src/cloud.js @@ -338,7 +338,7 @@ Cloud.prototype.logoutAlias = function (onSuccess, onError) { user.previous_username_admin, '', // password is irrelevant, but can't be null false, // ignored, will use the Admin's settings saved in the backend - function (username, role, response, previous_username_admin) { + function (username, role, previous_username_admin, response) { alert( response.message, function () { From 794acef485ba3d626e175b55e332089214502292 Mon Sep 17 00:00:00 2001 From: ochan1 Date: Thu, 1 Jul 2021 03:06:34 -0700 Subject: [PATCH 4/4] Swap Previous Username Admin and Response params --- src/cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cloud.js b/src/cloud.js index 8b01fcc3c..7c94713f2 100755 --- a/src/cloud.js +++ b/src/cloud.js @@ -289,8 +289,8 @@ Cloud.prototype.checkCredentials = function (onSuccess, onError, response) { null, user.username, user.role, - response ? JSON.parse(response) : null, - user.previous_username_admin + user.previous_username_admin, + response ? JSON.parse(response) : null ); } },