mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: prefer id over name when fetching owner id (#15590)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -227,7 +227,10 @@ func fetchItem(manager IModelManager, ctx context.Context, userCred mcclient.Tok
|
||||
}
|
||||
|
||||
func FetchUserInfo(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) {
|
||||
userStr, key := jsonutils.GetAnyString2(data, []string{"user", "user_id"})
|
||||
userStr, key := jsonutils.GetAnyString2(data, []string{
|
||||
"user_id",
|
||||
"user",
|
||||
})
|
||||
if len(userStr) > 0 {
|
||||
data.(*jsonutils.JSONDict).Remove(key)
|
||||
u, err := DefaultUserFetcher(ctx, userStr)
|
||||
@@ -249,7 +252,12 @@ func FetchUserInfo(ctx context.Context, data jsonutils.JSONObject) (mcclient.IId
|
||||
}
|
||||
|
||||
func FetchProjectInfo(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) {
|
||||
tenantId, key := jsonutils.GetAnyString2(data, []string{"project", "project_id", "tenant", "tenant_id"})
|
||||
tenantId, key := jsonutils.GetAnyString2(data, []string{
|
||||
"project_id",
|
||||
"tenant_id",
|
||||
"project",
|
||||
"tenant",
|
||||
})
|
||||
if len(tenantId) > 0 {
|
||||
data.(*jsonutils.JSONDict).Remove(key)
|
||||
t, err := DefaultProjectFetcher(ctx, tenantId)
|
||||
@@ -274,7 +282,11 @@ func FetchProjectInfo(ctx context.Context, data jsonutils.JSONObject) (mcclient.
|
||||
}
|
||||
|
||||
func FetchDomainInfo(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) {
|
||||
domainId, key := jsonutils.GetAnyString2(data, []string{"domain_id", "project_domain", "project_domain_id"})
|
||||
domainId, key := jsonutils.GetAnyString2(data, []string{
|
||||
"domain_id",
|
||||
"project_domain_id",
|
||||
"project_domain",
|
||||
})
|
||||
if len(domainId) > 0 {
|
||||
data.(*jsonutils.JSONDict).Remove(key)
|
||||
domain, err := DefaultDomainFetcher(ctx, domainId)
|
||||
|
||||
Reference in New Issue
Block a user