humingcheng commented on a change in pull request #1000:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1000#discussion_r637371423



##########
File path: server/service/rbac/dao/account_dao.go
##########
@@ -36,6 +37,9 @@ func CreateAccount(ctx context.Context, a *rbacmodel.Account) 
error {
 // UpdateAccount updates an account's info, except the password
 func UpdateAccount(ctx context.Context, name string, a *rbacmodel.Account) 
error {
        // todo params validation
+       if len(a.Roles) == 0 {

Review comment:
       不允许同时为空,其他情况有值则更新。

##########
File path: server/service/rbac/dao/role_dao.go
##########
@@ -50,17 +50,23 @@ func DeleteRole(ctx context.Context, name string) (bool, 
error) {
        return datasource.Instance().DeleteRole(ctx, name)
 }
 
-func EditRole(ctx context.Context, a *rbac.Role) error {
-       exist, err := datasource.Instance().RoleExist(ctx, a.Name)
+func EditRole(ctx context.Context, name string, a *rbac.Role) error {
+       exist, err := datasource.Instance().RoleExist(ctx, name)
        if err != nil {
-               log.Errorf(err, "can not edit account info")
+               log.Errorf(err, "check role [%s] exist failed", name)
                return err
        }
        if !exist {
                return datasource.ErrRoleCanNotEdit
        }
+       oldRole, err := GetRole(ctx, name)
+       if err != nil {
+               log.Errorf(err, "get role [%s] failed", name)
+               return err
+       }
+       oldRole.Perms = a.Perms
 
-       err = datasource.Instance().UpdateRole(ctx, a.Name, a)
+       err = datasource.Instance().UpdateRole(ctx, name, oldRole)

Review comment:
       Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to