fix(region): avoid panic when update user resource (#24071)

This commit is contained in:
屈轩
2026-01-13 18:20:57 +08:00
committed by GitHub
parent a640fb3d60
commit cfde0396c3
2 changed files with 1 additions and 6 deletions
+1 -1
View File
@@ -219,7 +219,7 @@ func SharableManagerFilterByOwner(ctx context.Context, manager IStandaloneModelM
resScope := manager.ResourceScope()
if resScope == rbacscope.ScopeUser {
targetProjectId := owner.GetProjectId()
if len(targetProjectId) == 0 {
if len(targetProjectId) == 0 && userCred != nil {
targetProjectId = userCred.GetProjectId()
}
subq := SharedResourceManager.Query("resource_id")
-5
View File
@@ -289,11 +289,6 @@ func (self *SKeypair) ValidateDeleteCondition(ctx context.Context, info *api.Key
return self.SStandaloneResourceBase.ValidateDeleteCondition(ctx, nil)
}
func totalKeypairCount(userId string) (int, error) {
q := KeypairManager.Query().Equals("owner_id", userId)
return q.CountWithError()
}
func (manager *SKeypairManager) FilterByOwner(ctx context.Context, q *sqlchemy.SQuery, man db.FilterByOwnerProvider, userCred mcclient.TokenCredential, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery {
return db.SharableManagerFilterByOwner(ctx, manager.GetISharableVirtualModelManager(), q, userCred, owner, scope)
}