snappymail/dev/App/Admin.js

37 lines
856 B
JavaScript
Raw Normal View History

import 'External/ko';
2015-11-19 01:32:29 +08:00
2021-03-10 18:44:48 +08:00
import { Settings, SettingsGet } from 'Common/Globals';
import { ThemeStore } 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
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() {
ThemeStore.populate();
2022-03-31 23:39:53 +08:00
this.start();
}
start() {
2021-12-28 21:49:21 +08:00
if (!Settings.app('adminAllowed')) {
rl.route.root();
setTimeout(() => location.href = '/', 1);
2021-03-16 21:15:05 +08:00
} else if (SettingsGet('Auth')) {
this.weakPassword(!!SettingsGet('WeakPassword'));
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
}
}
}