mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix(common): distinguish system and user log by is_system_account (#18316)
This commit is contained in:
@@ -67,6 +67,7 @@ func getDefaultAdminCred() *mcclient.SSimpleToken {
|
||||
token.ProjectDomain = prj.GetDomain().Name
|
||||
rol, _ := RoleManager.FetchRole("", api.SystemAdminRole, api.DEFAULT_DOMAIN_ID, "")
|
||||
token.Roles = rol.Name
|
||||
token.SystemAccount = true
|
||||
token.RoleIds = rol.Id
|
||||
return &token
|
||||
}
|
||||
|
||||
@@ -286,13 +286,14 @@ func (t *SAuthToken) GetSimpleUserCred(token string) (mcclient.TokenCredential,
|
||||
return nil, errors.Wrap(err, "UserManager.FetchUserExtended")
|
||||
}
|
||||
ret := mcclient.SSimpleToken{
|
||||
Token: token,
|
||||
UserId: t.UserId,
|
||||
User: userExt.Name,
|
||||
Domain: userExt.DomainName,
|
||||
DomainId: userExt.DomainId,
|
||||
Expires: t.ExpiresAt,
|
||||
Context: t.Context,
|
||||
Token: token,
|
||||
UserId: t.UserId,
|
||||
User: userExt.Name,
|
||||
Domain: userExt.DomainName,
|
||||
DomainId: userExt.DomainId,
|
||||
Expires: t.ExpiresAt,
|
||||
Context: t.Context,
|
||||
SystemAccount: userExt.IsSystemAccount,
|
||||
}
|
||||
var roles []models.SRole
|
||||
if len(t.ProjectId) > 0 {
|
||||
|
||||
@@ -44,6 +44,8 @@ type SSimpleToken struct {
|
||||
RoleIds string
|
||||
Expires time.Time
|
||||
|
||||
SystemAccount bool
|
||||
|
||||
Context SAuthContext
|
||||
}
|
||||
|
||||
@@ -184,7 +186,7 @@ func (this *SSimpleToken) GetServiceCatalog() IServiceCatalog {
|
||||
}
|
||||
|
||||
func (this *SSimpleToken) IsSystemAccount() bool {
|
||||
return true
|
||||
return this.SystemAccount
|
||||
}
|
||||
|
||||
func (this *SSimpleToken) GetLoginSource() string {
|
||||
@@ -218,6 +220,7 @@ func SimplifyToken(token TokenCredential) TokenCredential {
|
||||
Source: token.GetLoginSource(),
|
||||
Ip: token.GetLoginIp(),
|
||||
},
|
||||
SystemAccount: token.IsSystemAccount(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user