From 93d8b5a419a7bd5caf062ef95574678ce2a6367e Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 18 Oct 2022 23:32:47 +0200 Subject: [PATCH] Improve some login/logout handling --- dev/App/Abstract.js | 8 +++++--- dev/App/User.js | 9 +-------- dev/Common/Translator.js | 2 +- dev/View/Popup/Ask.js | 8 ++++---- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/dev/App/Abstract.js b/dev/App/Abstract.js index d7d6f6c5b3..02d547c4e0 100644 --- a/dev/App/Abstract.js +++ b/dev/App/Abstract.js @@ -17,14 +17,16 @@ export class AbstractApp { this.Remote = Remote; } - logoutReload() { - const url = logoutLink(); - + logoutReload(url) { + url = url || logoutLink(); if (location.href !== url) { setTimeout(() => location.href = url, 100); } else { rl.route.reload(); } + // this does not work due to ViewModelClass.__builded = true; +// rl.settings.set('Auth', false); +// rl.app.start(); } bootstart() { diff --git a/dev/App/User.js b/dev/App/User.js index 2049576bf5..969ec32ec6 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -200,14 +200,7 @@ export class AppUser extends AbstractApp { } logout() { - Remote.request('Logout', () => { - const customLogoutLink = Settings.app('customLogoutLink'); - if (customLogoutLink) { - location.href = customLogoutLink; - } else { - rl.logoutReload() - } - }); + Remote.request('Logout', () => rl.logoutReload(Settings.app('customLogoutLink'))); } bootstart() { diff --git a/dev/Common/Translator.js b/dev/Common/Translator.js index 6a48c6c7d9..38401f0c81 100644 --- a/dev/Common/Translator.js +++ b/dev/Common/Translator.js @@ -34,7 +34,7 @@ export const * @returns {string} */ i18n = (key, valueList, defaulValue) => { - let result = defaulValue || key; + let result = null == defaulValue ? key : defaulValue; let path = key.split('/'); if (I18N_DATA[path[0]] && path[1]) { result = I18N_DATA[path[0]][path[1]] || result; diff --git a/dev/View/Popup/Ask.js b/dev/View/Popup/Ask.js index ba1c0d8c51..40ba622cf3 100644 --- a/dev/View/Popup/Ask.js +++ b/dev/View/Popup/Ask.js @@ -26,13 +26,13 @@ export class AskPopupView extends AbstractViewPopup { yesClick() { this.close(); - isFunction(this.fYesAction) && this.fYesAction(); + isFunction(this.fYesAction) && this.fYesAction(this); } noClick() { this.close(); - isFunction(this.fNoAction) && this.fNoAction(); + isFunction(this.fNoAction) && this.fNoAction(this); } /** @@ -86,7 +86,7 @@ AskPopupView.password = function(sAskDesc, btnText) { return new Promise(resolve => { this.showModal([ sAskDesc, - () => resolve(this.__vm.passphrase()), + view => resolve(view.passphrase()), () => resolve(null), true, 1, @@ -99,7 +99,7 @@ AskPopupView.credentials = function(sAskDesc, btnText) { return new Promise(resolve => { this.showModal([ sAskDesc, - () => resolve({username:this.__vm.username(), password:this.__vm.passphrase()}), + view => resolve({username:view.username(), password:view.passphrase()}), () => resolve(null), true, 3,