mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: fail to delete cas idp due to readonly domain (#23218)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -320,8 +320,12 @@ func (domain *SDomain) GetIdpCount() (int, error) {
|
||||
}
|
||||
|
||||
func (domain *SDomain) ValidateDeleteCondition(ctx context.Context, info *api.DomainDetails) error {
|
||||
return domain.validateDeleteConditionInternal(ctx, info, false)
|
||||
}
|
||||
|
||||
func (domain *SDomain) validateDeleteConditionInternal(ctx context.Context, info *api.DomainDetails, skipIdpCheck bool) error {
|
||||
if gotypes.IsNil(info) {
|
||||
info := &api.DomainDetails{}
|
||||
info = &api.DomainDetails{}
|
||||
if usage, _ := DomainManager.TotalResourceCount([]string{domain.Id}); usage != nil {
|
||||
info.DomainUsage, _ = usage[domain.Id]
|
||||
}
|
||||
@@ -330,7 +334,7 @@ func (domain *SDomain) ValidateDeleteCondition(ctx context.Context, info *api.Do
|
||||
info.IdpResourceInfo = idpInfo[0]
|
||||
}
|
||||
}
|
||||
if len(info.IdpId) > 0 {
|
||||
if !skipIdpCheck && len(info.IdpId) > 0 {
|
||||
return httperrors.NewForbiddenError("readonly")
|
||||
}
|
||||
if domain.Id == api.DEFAULT_DOMAIN_ID {
|
||||
|
||||
@@ -913,7 +913,7 @@ func (self *SIdentityProvider) Purge(ctx context.Context, userCred mcclient.Toke
|
||||
return errors.Wrap(err, "domains[i].UnlinkIdp")
|
||||
}
|
||||
} else {
|
||||
err = domains[i].ValidateDeleteCondition(ctx, nil)
|
||||
err = domains[i].validateDeleteConditionInternal(ctx, nil, true)
|
||||
if err != nil {
|
||||
db.OpsLog.LogEvent(&domains[i], db.ACT_DELETE_FAIL, err, userCred)
|
||||
return errors.Wrap(err, "domain.ValidateDeleteCondition")
|
||||
|
||||
Reference in New Issue
Block a user