From 2c247efd0fdd3f944040c08bfc6d653f4cd295d7 Mon Sep 17 00:00:00 2001 From: Chaim Lev-Ari Date: Tue, 28 Feb 2023 16:49:46 +0200 Subject: [PATCH] fix(settings/oauth): show internal auth prompt by default [EE-4576] (#8481) * fix(settings/oauth): show internal auth prompt by default [EE-4576] fix [EE-4576] * fix(oauth): use new confirm modal --- .../oauth-settings.controller.js | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/app/portainer/oauth/components/oauth-settings/oauth-settings.controller.js b/app/portainer/oauth/components/oauth-settings/oauth-settings.controller.js index 096512792..52d2e4867 100644 --- a/app/portainer/oauth/components/oauth-settings/oauth-settings.controller.js +++ b/app/portainer/oauth/components/oauth-settings/oauth-settings.controller.js @@ -1,14 +1,18 @@ import { baseHref } from '@/portainer/helpers/pathHelper'; -import { isLimitedToBE } from '@/react/portainer/feature-flags/feature-flags.service'; import { FeatureId } from '@/react/portainer/feature-flags/enums'; +import { isLimitedToBE } from '@/react/portainer/feature-flags/feature-flags.service'; +import { ModalType } from '@@/modals'; +import { confirm } from '@@/modals/confirm'; +import { buildConfirmButton } from '@@/modals/utils'; + import providers, { getProviderByUrl } from './providers'; const MS_TENANT_ID_PLACEHOLDER = 'TENANT_ID'; export default class OAuthSettingsController { /* @ngInject */ - constructor($scope) { - Object.assign(this, { $scope }); + constructor($scope, $async) { + Object.assign(this, { $scope, $async }); this.limitedFeature = FeatureId.HIDE_INTERNAL_AUTH; this.limitedFeatureClass = 'limited-be'; @@ -69,15 +73,30 @@ export default class OAuthSettingsController { updateSSO(checked) { this.$scope.$evalAsync(() => { this.settings.SSO = checked; - this.onChangeHideInternalAuth(checked); + this.settings.HideInternalAuth = false; }); } - onChangeHideInternalAuth(checked) { - this.$scope.$evalAsync(() => { - if (!this.isLimitedToBE) { - this.settings.HideInternalAuth = checked; + async onChangeHideInternalAuth(checked) { + this.$async(async () => { + if (this.isLimitedToBE) { + return; } + + if (checked) { + const confirmed = await confirm({ + title: 'Hide internal authentication prompt', + message: 'By hiding internal authentication prompt, you will only be able to login via SSO. Are you sure?', + confirmButton: buildConfirmButton('Confirm', 'btn-warning'), + modalType: ModalType.Warn, + }); + + if (!confirmed) { + return; + } + } + + this.settings.HideInternalAuth = checked; }); }