mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): avoid panic when update user resource (#24072)
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user