fix: disable policy update when enable three member system

This commit is contained in:
Qiu Jian
2023-05-17 23:36:37 +08:00
parent 3848411984
commit cb131ebf7d
+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
}