Improve some login/logout handling

This commit is contained in:
the-djmaze 2022-10-18 23:32:47 +02:00
parent b77854e421
commit 93d8b5a419
4 changed files with 11 additions and 16 deletions

View file

@ -17,14 +17,16 @@ export class AbstractApp {
this.Remote = Remote; this.Remote = Remote;
} }
logoutReload() { logoutReload(url) {
const url = logoutLink(); url = url || logoutLink();
if (location.href !== url) { if (location.href !== url) {
setTimeout(() => location.href = url, 100); setTimeout(() => location.href = url, 100);
} else { } else {
rl.route.reload(); rl.route.reload();
} }
// this does not work due to ViewModelClass.__builded = true;
// rl.settings.set('Auth', false);
// rl.app.start();
} }
bootstart() { bootstart() {

View file

@ -200,14 +200,7 @@ export class AppUser extends AbstractApp {
} }
logout() { logout() {
Remote.request('Logout', () => { Remote.request('Logout', () => rl.logoutReload(Settings.app('customLogoutLink')));
const customLogoutLink = Settings.app('customLogoutLink');
if (customLogoutLink) {
location.href = customLogoutLink;
} else {
rl.logoutReload()
}
});
} }
bootstart() { bootstart() {

View file

@ -34,7 +34,7 @@ export const
* @returns {string} * @returns {string}
*/ */
i18n = (key, valueList, defaulValue) => { i18n = (key, valueList, defaulValue) => {
let result = defaulValue || key; let result = null == defaulValue ? key : defaulValue;
let path = key.split('/'); let path = key.split('/');
if (I18N_DATA[path[0]] && path[1]) { if (I18N_DATA[path[0]] && path[1]) {
result = I18N_DATA[path[0]][path[1]] || result; result = I18N_DATA[path[0]][path[1]] || result;

View file

@ -26,13 +26,13 @@ export class AskPopupView extends AbstractViewPopup {
yesClick() { yesClick() {
this.close(); this.close();
isFunction(this.fYesAction) && this.fYesAction(); isFunction(this.fYesAction) && this.fYesAction(this);
} }
noClick() { noClick() {
this.close(); 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 => { return new Promise(resolve => {
this.showModal([ this.showModal([
sAskDesc, sAskDesc,
() => resolve(this.__vm.passphrase()), view => resolve(view.passphrase()),
() => resolve(null), () => resolve(null),
true, true,
1, 1,
@ -99,7 +99,7 @@ AskPopupView.credentials = function(sAskDesc, btnText) {
return new Promise(resolve => { return new Promise(resolve => {
this.showModal([ this.showModal([
sAskDesc, sAskDesc,
() => resolve({username:this.__vm.username(), password:this.__vm.passphrase()}), view => resolve({username:view.username(), password:view.passphrase()}),
() => resolve(null), () => resolve(null),
true, true,
3, 3,