管理员也支持AccessKey

This commit is contained in:
GoEdgeLab
2021-06-20 19:23:02 +08:00
parent 1b74c3ebe0
commit b1adf12624
20 changed files with 459 additions and 42 deletions

View File

@@ -7,7 +7,7 @@ import (
"github.com/iwind/TeaGo/maps"
)
// 查找用户基本信息
// InitUser 查找用户基本信息
func InitUser(p *actionutils.ParentAction, userId int64) error {
resp, err := p.RPC().UserRPC().FindEnabledUser(p.AdminContext(), &pb.FindEnabledUserRequest{UserId: userId})
if err != nil {
@@ -16,10 +16,21 @@ func InitUser(p *actionutils.ParentAction, userId int64) error {
if resp.User == nil {
return errors.New("not found user")
}
// AccessKey数量
countAccessKeysResp, err := p.RPC().UserAccessKeyRPC().CountAllEnabledUserAccessKeys(p.AdminContext(), &pb.CountAllEnabledUserAccessKeysRequest{
AdminId: 0,
UserId: userId,
})
if err != nil {
return err
}
p.Data["user"] = maps.Map{
"id": userId,
"fullname": resp.User.Fullname,
"username": resp.User.Username,
"id": userId,
"fullname": resp.User.Fullname,
"username": resp.User.Username,
"countAccessKeys": countAccessKeysResp.Count,
}
return nil
}