Merge pull request #17067 from swordqiu/automated-cherry-pick-of-#17066-upstream-release-3.10

Automated cherry pick of #17066: fix: disable policy update when enable three member system
This commit is contained in:
Zexi Li
2023-05-18 02:17:31 +08:00
committed by GitHub
+8 -6
View File
@@ -687,12 +687,14 @@ func (policy *SPolicy) ValidateUpdateCondition(ctx context.Context) error {
//if policy.IsSystem.IsTrue() {
// return errors.Wrap(httperrors.ErrForbidden, "system policy")
//}
rps, err := RolePolicyManager.fetchByPolicyId(policy.Id)
if err != nil {
return errors.Wrap(err, "fetchByPolicyId")
}
if len(rps) > 0 {
return errors.Wrap(httperrors.ErrForbidden, "policy in use")
if options.Options.ThreeAdminRoleSystem {
rps, err := RolePolicyManager.fetchByPolicyId(policy.Id)
if err != nil {
return errors.Wrap(err, "fetchByPolicyId")
}
if len(rps) > 0 {
return errors.Wrap(httperrors.ErrForbidden, "policy in use")
}
}
return nil
}