mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(core-authentication): authentication request
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ export class ServerConfigurationService {
|
||||
try {
|
||||
await this.graphQLService.gql.setDefaultNavigatorSettings({ settings: this.state.navigatorConfig });
|
||||
await this.graphQLService.gql.configureServer({ configuration: this.state.serverConfig });
|
||||
this.usersResource.refreshAll();
|
||||
this.usersResource.refreshAllLazy();
|
||||
} catch (exception) {
|
||||
this.notificationService.logException(exception, 'Can\'t save server configuration');
|
||||
|
||||
|
||||
@@ -175,6 +175,11 @@ export class UsersResource extends CachedMapResource<string, AdminUserInfo> {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
refreshAllLazy() {
|
||||
this.markOutdated('all');
|
||||
this.metadata.set('all', false);
|
||||
}
|
||||
|
||||
protected async loader(key: ResourceKey<string>): Promise<Map<string, AdminUserInfo>> {
|
||||
const userId = key === 'all' ? undefined : key as string;
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import { injectable, Bootstrap } from '@cloudbeaver/core-di';
|
||||
import { NotificationService } from '@cloudbeaver/core-events';
|
||||
import { ServerService } from '@cloudbeaver/core-root';
|
||||
|
||||
import { AuthenticationService } from './AuthenticationService';
|
||||
import { AuthDialogService } from './Dialog/AuthDialogService';
|
||||
import { UserInfo } from './UserInfo';
|
||||
|
||||
@@ -24,7 +23,6 @@ export class AuthMenuService extends Bootstrap {
|
||||
private authDialogService: AuthDialogService,
|
||||
private authInfoService: AuthInfoService,
|
||||
private settingsMenuService: SettingsMenuService,
|
||||
private authenticationService: AuthenticationService,
|
||||
private notificationService: NotificationService,
|
||||
private topNavService: TopNavService,
|
||||
private administrationTopAppBarService: AdministrationTopAppBarService,
|
||||
@@ -64,7 +62,6 @@ export class AuthMenuService extends Bootstrap {
|
||||
private async logout() {
|
||||
try {
|
||||
await this.authInfoService.logout();
|
||||
await this.authenticationService.auth();
|
||||
} catch (exception) {
|
||||
this.notificationService.logException(exception, 'Can\'t logout');
|
||||
}
|
||||
|
||||
@@ -8,14 +8,16 @@
|
||||
|
||||
import { AuthInfoService } from '@cloudbeaver/core-authentication';
|
||||
import { injectable, Bootstrap } from '@cloudbeaver/core-di';
|
||||
import { ServerService } from '@cloudbeaver/core-root';
|
||||
import { ServerService, SessionService } from '@cloudbeaver/core-root';
|
||||
|
||||
import { AuthDialogService } from './Dialog/AuthDialogService';
|
||||
|
||||
@injectable()
|
||||
export class AuthenticationService extends Bootstrap {
|
||||
private authenticating = false;
|
||||
constructor(
|
||||
private serverService: ServerService,
|
||||
private sessionService: SessionService,
|
||||
private authDialogService: AuthDialogService,
|
||||
private authInfoService: AuthInfoService,
|
||||
) {
|
||||
@@ -23,29 +25,37 @@ export class AuthenticationService extends Bootstrap {
|
||||
}
|
||||
|
||||
async auth() {
|
||||
const config = await this.serverService.config.load(null);
|
||||
if (!config) {
|
||||
throw new Error('Can\'t configure Authentication');
|
||||
}
|
||||
|
||||
if (!config.authenticationEnabled) {
|
||||
if (this.authenticating) {
|
||||
return;
|
||||
}
|
||||
this.authenticating = true;
|
||||
try {
|
||||
const config = await this.serverService.config.load(null);
|
||||
if (!config) {
|
||||
throw new Error('Can\'t configure Authentication');
|
||||
}
|
||||
|
||||
const userInfo = await this.authInfoService.updateAuthInfo();
|
||||
if (userInfo) {
|
||||
return;
|
||||
}
|
||||
if (!config.authenticationEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.anonymousAccessEnabled) {
|
||||
await this.authDialogService.showLoginForm(true);
|
||||
const userInfo = await this.authInfoService.updateAuthInfo();
|
||||
if (userInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.anonymousAccessEnabled) {
|
||||
await this.authDialogService.showLoginForm(true);
|
||||
}
|
||||
} finally {
|
||||
this.authenticating = false;
|
||||
}
|
||||
}
|
||||
|
||||
register(): void | Promise<void> { }
|
||||
|
||||
load() {
|
||||
// we do not await it because to unblock app loading
|
||||
this.auth();
|
||||
register(): void | Promise<void> {
|
||||
this.serverService.config.onDataUpdate.subscribe(this.auth.bind(this));
|
||||
this.sessionService.session.onDataUpdate.subscribe(this.auth.bind(this));
|
||||
}
|
||||
|
||||
load() { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user