fix: disable policy update when enable three member system

This commit is contained in:
Qiu Jian
2023-05-17 23:33:29 +08:00
parent ec068bc6dc
commit def00fc871
+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
}