snappymail/dev/App/Admin.js

53 lines
1.2 KiB
JavaScript
Raw Normal View History

import 'External/ko';
2015-11-19 01:32:29 +08:00
2024-03-07 08:16:58 +08:00
import { SettingsGet, SettingsAdmin } from 'Common/Globals';
2023-03-18 06:20:42 +08:00
import { initThemes } from 'Stores/Theme';
2015-11-19 01:32:29 +08:00
import Remote from 'Remote/Admin/Fetch';
2015-11-19 01:32:29 +08:00
2019-07-05 03:19:24 +08:00
import { SettingsAdminScreen } from 'Screen/Admin/Settings';
import { LoginAdminScreen } from 'Screen/Admin/Login';
2016-07-07 07:11:13 +08:00
2020-09-17 05:19:34 +08:00
import { startScreens } from 'Knoin/Knoin';
2019-07-05 03:19:24 +08:00
import { AbstractApp } from 'App/Abstract';
2015-11-19 01:32:29 +08:00
import { AskPopupView } from 'View/Popup/Ask';
2022-03-31 23:39:53 +08:00
export class AdminApp extends AbstractApp {
2016-07-16 05:29:42 +08:00
constructor() {
2015-11-19 01:32:29 +08:00
super(Remote);
2021-03-16 21:15:05 +08:00
this.weakPassword = ko.observable(false);
2015-11-19 01:32:29 +08:00
}
2022-03-31 23:39:53 +08:00
refresh() {
2023-03-18 06:20:42 +08:00
initThemes();
2022-03-31 23:39:53 +08:00
this.start();
}
start() {
2024-03-07 08:16:58 +08:00
// if (!Settings.app('adminAllowed')) {
if (!SettingsAdmin('allowed')) {
rl.route.root();
setTimeout(() => location.href = '/', 1);
2021-03-16 21:15:05 +08:00
} else if (SettingsGet('Auth')) {
this.weakPassword(SettingsGet('weakPassword'));
2021-03-16 21:15:05 +08:00
startScreens([SettingsAdminScreen]);
2019-07-05 03:19:24 +08:00
} else {
2021-03-16 21:15:05 +08:00
startScreens([LoginAdminScreen]);
2015-11-19 01:32:29 +08:00
}
}
}
AskPopupView.credentials = function(sAskDesc, btnText) {
return new Promise(resolve => {
this.showModal([
sAskDesc,
view => resolve({username:view.username(), password:view.passphrase()}),
() => resolve(null),
true,
3,
btnText
]);
});
};