Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: only workspace admin can change password restriction (#13856)

ecmadao72d8c3548eef
diff --git a/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vue b/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vue
index a39add27fd..9cb39599df 100644
--- a/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vue
+++ b/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vue
@@ -10,7 +10,7 @@
<div class="flex items-center space-x-2">
<NInputNumber
:value="passwordRestrictionSetting.minLength"
- :readonly="!allowEdit"
+ :readonly="!hasPermission"
class="w-24"
:min="1"
:placeholder="'Minimum length'"
@@ -35,7 +35,7 @@
</div>
<NCheckbox
:checked="passwordRestrictionSetting.requireNumber"
- :readonly="!allowEdit"
+ :readonly="!hasPermission"
@update:checked="
(val) => {
onUpdate({ requireNumber: val });
@@ -50,7 +50,7 @@
</NCheckbox>
<NCheckbox
:checked="passwordRestrictionSetting.requireLetter"
- :readonly="!allowEdit"
+ :readonly="!hasPermission"
@update:checked="
(val) => {
onUpdate({ requireLetter: val });
@@ -65,7 +65,7 @@
</NCheckbox>
<NCheckbox
:checked="passwordRestrictionSetting.requireUppercaseLetter"
- :readonly="!allowEdit"
+ :readonly="!hasPermission"
@update:checked="
(val) => {
onUpdate({ requireUppercaseLetter: val });
@@ -82,7 +82,7 @@
</NCheckbox>
<NCheckbox
:checked="passwordRestrictionSetting.requireSpecialCharacter"
- :readonly="!allowEdit"
+ :readonly="!hasPermission"
@update:checked="
(val) => {
onUpdate({ requireSpecialCharacter: val });
@@ -99,7 +99,7 @@
</NCheckbox>
<NCheckbox
:checked="passwordRestrictionSetting.requireResetPasswordForFirstLogin"
- :readonly="!allowEdit"
+ :readonly="!hasPermission"
@update:checked="
(val) => {
onUpdate({ requireResetPasswordForFirstLogin: val });
@@ -116,7 +116,7 @@
</NCheckbox>
<NCheckbox
:checked="!!passwordRestrictionSetting.passwordRotation"
- :readonly="!allowEdit"
+ :readonly="!hasPermission"
class="!flex !items-center"
@update:checked="
(checked) => {
@@ -146,7 +146,7 @@
)
)
"
- :readonly="!allowEdit"
+ :readonly="!hasPermission"
:min="1"
class="w-24 mx-2"
:size="'small'"
@@ -183,13 +183,15 @@ import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import { featureToRef, pushNotification } from "@/store";
import { useSettingV1Store } from "@/store/modules/v1/setting";
+import { PresetRoleType } from "@/types";
import { Duration } from "@/types/proto/google/protobuf/duration";
import { PasswordRestrictionSetting } from "@/types/proto/v1/setting_service";
+import { hasWorkspaceLevelRole } from "@/utils";
import { FeatureBadge, FeatureModal } from "../FeatureGuard";
const DEFAULT_MIN_LENGTH = 8;
-defineProps<{
+const props = defineProps<{
allowEdit: boolean;
}>();
@@ -198,6 +200,12 @@ const settingV1Store = useSettingV1Store();
const showFeatureModal = ref<boolean>(false);
const hasPasswordFeature = featureToRef("bb.feature.password-restriction");
+const hasPermission = computed(() => {
+ return (
+ props.allowEdit && hasWorkspaceLevelRole(PresetRoleType.WORKSPACE_ADMIN)
+ );
+});
+
const passwordRestrictionSetting = computed(
() =>
settingV1Store.getSettingByName("bb.workspace.password-restriction")?.value