MSP-6636 add roleNames to get_profile method
This commit is contained in:
1 parent
187e1f07a0
commit
7de82862bd
4 files changed
+14
-5
No files matched your search
+4
-3
@@ -33,6 +33,10 @@ definitions:
|
||||
type: array
|
||||
role:
|
||||
type: string
|
||||
roleNames:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
roles:
|
||||
items:
|
||||
type: integer
|
||||
@@ -233,7 +237,6 @@ definitions:
|
||||
domain.SecureAuthResponse:
|
||||
properties:
|
||||
adminId:
|
||||
format: int64
|
||||
type: integer
|
||||
authenticated:
|
||||
type: boolean
|
||||
@@ -315,7 +318,6 @@ definitions:
|
||||
firstName:
|
||||
type: string
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
lastName:
|
||||
type: string
|
||||
@@ -334,7 +336,6 @@ definitions:
|
||||
type: string
|
||||
ids:
|
||||
items:
|
||||
format: int64
|
||||
type: integer
|
||||
type: array
|
||||
limit:
|
||||
|
||||
@@ -34,6 +34,7 @@ type AdminUserShort struct {
|
||||
Email string `validate:"required"`
|
||||
Role string
|
||||
Roles []int
|
||||
RoleNames []string
|
||||
Permissions []string
|
||||
IdleTimeoutMs int
|
||||
}
|
||||
|
||||
+7
-2
@@ -105,8 +105,9 @@ func (u User) GetProfileById(ctx context.Context, userId int64) (*domain.AdminUs
|
||||
roleIds := RolesIds(roles)
|
||||
|
||||
var (
|
||||
roleList []entity.Role
|
||||
roleName string
|
||||
roleList []entity.Role
|
||||
roleName string
|
||||
roleNames []string
|
||||
)
|
||||
if len(roleIds) != 0 {
|
||||
roleList, err = u.roleRepoUser.GetRoleByIds(ctx, roleIds)
|
||||
@@ -115,6 +116,9 @@ func (u User) GetProfileById(ctx context.Context, userId int64) (*domain.AdminUs
|
||||
}
|
||||
if len(roleList) > 0 {
|
||||
roleName = roleList[0].Name
|
||||
for _, r := range roleList {
|
||||
roleNames = append(roleNames, r.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +128,7 @@ func (u User) GetProfileById(ctx context.Context, userId int64) (*domain.AdminUs
|
||||
Email: user.Email,
|
||||
Role: roleName,
|
||||
Roles: roleIds,
|
||||
RoleNames: roleNames,
|
||||
IdleTimeoutMs: u.idleTimeoutMs,
|
||||
Permissions: mergePermissions(roleList),
|
||||
}, nil
|
||||
|
||||
@@ -99,6 +99,7 @@ func (s *UserTestSuite) TestGetProfileHappyPath() {
|
||||
Email: "a@a.ru",
|
||||
Role: "admin",
|
||||
Roles: []int{1},
|
||||
RoleNames: []string{"admin"},
|
||||
Permissions: []string{},
|
||||
}
|
||||
s.Require().Equal(expected, response)
|
||||
@@ -151,6 +152,7 @@ func (s *UserTestSuite) TestGetProfileSudir() {
|
||||
Email: "a@b.ru",
|
||||
Role: "admin",
|
||||
Roles: []int{1},
|
||||
RoleNames: []string{"admin"},
|
||||
Permissions: []string{},
|
||||
}
|
||||
s.Require().Equal(expected, response)
|
||||
|
||||
Reference in new issue
Block a user