mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(plugin-authentication): CB-924 ignore enabled auth provider on administration page
This commit is contained in:
+6
-2
@@ -249,7 +249,9 @@ export class AdministrationScreenService {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(await this.isAccessProvided(state))) {
|
||||
const accessProvided = await this.isAccessProvided(state);
|
||||
|
||||
if (!accessProvided) {
|
||||
this.screenService.navigateToRoot();
|
||||
return false;
|
||||
}
|
||||
@@ -269,7 +271,9 @@ export class AdministrationScreenService {
|
||||
|
||||
await this.ensurePermissions.execute();
|
||||
|
||||
if (!(await this.permissionsService.hasAsync(EAdminPermission.admin))) {
|
||||
const administrator = await this.permissionsService.hasAsync(EAdminPermission.admin);
|
||||
|
||||
if (!administrator) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,17 +46,16 @@ export class UserInfoResource extends CachedDataResource<UserInfo | null, void>
|
||||
}
|
||||
|
||||
async login(provider: string, credentials: Record<string, string>, link?: boolean): Promise<UserInfo | null> {
|
||||
const processedCredentials = await this.authProviderService.processCredentials(provider, credentials);
|
||||
|
||||
const { authToken } = await this.graphQLService.sdk.authLogin({
|
||||
provider,
|
||||
credentials: processedCredentials,
|
||||
linkUser: link,
|
||||
customIncludeOriginDetails: true,
|
||||
});
|
||||
|
||||
await this.performUpdate(undefined, undefined, async () => {
|
||||
const processedCredentials = await this.authProviderService.processCredentials(provider, credentials);
|
||||
|
||||
// TODO: will be replaced with another function
|
||||
const { authToken } = await this.graphQLService.sdk.authLogin({
|
||||
provider,
|
||||
credentials: processedCredentials,
|
||||
linkUser: link,
|
||||
customIncludeOriginDetails: true,
|
||||
});
|
||||
|
||||
if (this.data === null || link) {
|
||||
this.data = await this.loader();
|
||||
} else {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import styled, { css } from 'reshadow';
|
||||
|
||||
import { AdministrationScreenService } from '@cloudbeaver/core-administration';
|
||||
import { UserInfoResource } from '@cloudbeaver/core-authentication';
|
||||
import {
|
||||
SubmittingForm, ErrorMessage, TabsState, TabList, Tab, TabTitle, Loader
|
||||
@@ -91,16 +92,22 @@ interface IAuthPayload {
|
||||
}
|
||||
|
||||
export const AuthDialog: DialogComponent<IAuthPayload, null> = observer(function AuthDialog({
|
||||
payload: { provider, link },
|
||||
payload: {
|
||||
provider,
|
||||
link = false,
|
||||
},
|
||||
options,
|
||||
rejectDialog,
|
||||
}) {
|
||||
const administrationScreenService = useService(AdministrationScreenService);
|
||||
const userInfo = useService(UserInfoResource);
|
||||
const controller = useController(AuthDialogController, link || false, rejectDialog);
|
||||
const controller = useController(AuthDialogController, link, rejectDialog);
|
||||
const translate = useTranslate();
|
||||
|
||||
if (provider) {
|
||||
controller.selectProvider(provider);
|
||||
} else {
|
||||
controller.admin = administrationScreenService.activeScreen !== null;
|
||||
}
|
||||
|
||||
const showTabs = !provider && controller.providers.length > 1;
|
||||
|
||||
@@ -26,14 +26,19 @@ export class AuthDialogController implements IInitializableController, IDestruct
|
||||
}
|
||||
|
||||
get providers(): AuthProvider[] {
|
||||
return this.authProvidersResource
|
||||
.getEnabledProviders()
|
||||
.sort(this.compareProviders);
|
||||
let providers = this.authProvidersResource.values;
|
||||
|
||||
if (!this.admin) {
|
||||
providers = this.authProvidersResource.getEnabledProviders();
|
||||
}
|
||||
|
||||
return providers.sort(this.compareProviders);
|
||||
}
|
||||
|
||||
readonly error = new GQLErrorCatcher();
|
||||
private isDistructed = false;
|
||||
private link!: boolean;
|
||||
admin: boolean;
|
||||
private close!: () => void;
|
||||
|
||||
constructor(
|
||||
@@ -46,11 +51,14 @@ export class AuthDialogController implements IInitializableController, IDestruct
|
||||
provider: observable,
|
||||
isAuthenticating: observable,
|
||||
credentials: observable,
|
||||
admin: observable,
|
||||
providers: computed,
|
||||
});
|
||||
|
||||
this.admin = false;
|
||||
}
|
||||
|
||||
init(link: boolean, onClose: () => void) {
|
||||
init(link: boolean, onClose: () => void): void {
|
||||
this.link = link;
|
||||
this.close = onClose;
|
||||
this.loadProviders();
|
||||
@@ -95,8 +103,9 @@ export class AuthDialogController implements IInitializableController, IDestruct
|
||||
private async loadProviders() {
|
||||
try {
|
||||
await this.authProvidersResource.loadAll();
|
||||
|
||||
if (this.providers.length > 0) {
|
||||
this.provider = this.providers[0];
|
||||
this.provider = this.providers.find(provider => provider.defaultProvider) ?? this.providers[0];
|
||||
}
|
||||
} catch (exception) {
|
||||
this.notificationService.logException(exception, 'Can\'t load auth providers');
|
||||
|
||||
Reference in New Issue
Block a user