chore(authentication): minor improvements

This commit is contained in:
Wroud
2020-05-14 16:23:29 +03:00
parent e4acc7710a
commit aced28f537
2 changed files with 13 additions and 11 deletions
@@ -42,7 +42,7 @@ export class AuthMenuService {
SettingsMenuService.settingsMenuToken,
{
id: 'logout',
order: 0,
order: Number.MAX_SAFE_INTEGER,
isHidden: () => !this.serverService.config.data?.authenticationEnabled || !this.authInfoService.userInfo,
title: 'authentication_logout',
onClick: this.logout.bind(this),
@@ -21,20 +21,22 @@ export class AuthenticationService {
) { }
async auth() {
if (await this.isForceAuthentication()) {
await this.authDialogService.showLoginForm(true);
}
}
async isForceAuthentication() {
const config = await this.serverService.config.load();
if (!config) {
throw new Error('Can\'t configure Authentication');
}
const userInfo = await this.authInfoService.updateAuthInfo();
return !config.anonymousAccessEnabled
&& config.authenticationEnabled
&& !userInfo;
if (!config.authenticationEnabled) {
return;
}
const userInfo = await this.authInfoService.updateAuthInfo();
if (userInfo) {
return;
}
if (!config.anonymousAccessEnabled) {
await this.authDialogService.showLoginForm(true);
}
}
}