Skip to content

Commit

Permalink
update view user with identity from name
Browse files Browse the repository at this point in the history
Signed-off-by: ianmuchyri <[email protected]>
  • Loading branch information
ianmuchyri committed Nov 30, 2023
1 parent 7a54115 commit ca929c8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ui/api/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ func viewMemberEndpoint(svc ui.Service) endpoint.Endpoint {
return nil, err
}

res, err := svc.ViewMember(req.token, req.UserName)
res, err := svc.ViewMember(req.token, req.UserIdentity)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions ui/api/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,15 +1158,15 @@ func (lm *loggingMiddleware) UnassignMember(token, orgID string, req sdk.UsersRe
}

// ViewMember adds logging middleware to view member method.
func (lm *loggingMiddleware) ViewMember(token, id string) (b []byte, err error) {
func (lm *loggingMiddleware) ViewMember(token, identity string) (b []byte, err error) {
defer func(begin time.Time) {
message := fmt.Sprintf("Method view_member for member %s took %s to complete", id, time.Since(begin))
message := fmt.Sprintf("Method view_member for member %s took %s to complete", identity, time.Since(begin))
if err != nil {
lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err))
return
}
lm.logger.Info(fmt.Sprintf("%s without errors.", message))
}(time.Now())

return lm.svc.ViewMember(token, id)
return lm.svc.ViewMember(token, identity)
}
4 changes: 2 additions & 2 deletions ui/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,11 +841,11 @@ func (mm *metricsMiddleware) UnassignMember(token, orgID string, req sdk.UsersRe
}

// ViewMember adds metrics middleware to view member method.
func (mm *metricsMiddleware) ViewMember(token, id string) (b []byte, err error) {
func (mm *metricsMiddleware) ViewMember(token, identity string) (b []byte, err error) {
defer func(begin time.Time) {
mm.counter.With("method", "view_member").Add(1)
mm.latency.With("method", "view_member").Observe(time.Since(begin).Seconds())
}(time.Now())

return mm.svc.ViewMember(token, id)
return mm.svc.ViewMember(token, identity)
}
6 changes: 3 additions & 3 deletions ui/api/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -919,15 +919,15 @@ func (req assignMemberReq) validate() error {
}

type viewMemberReq struct {
token string
UserName string `json:"userName"`
token string
UserIdentity string `json:"userIdentity"`
}

func (req viewMemberReq) validate() error {
if req.token == "" {
return errAuthentication
}
if req.UserName == "" {
if req.UserIdentity == "" {
return errMalformedEntity
}
return nil
Expand Down
7 changes: 4 additions & 3 deletions ui/api/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
relationKey = "relation"
organizationKey = "organization"
permissionKey = "permission"
identityKey = "identity"
defPage = 1
defLimit = 10
defKey = ""
Expand Down Expand Up @@ -1897,14 +1898,14 @@ func decodeViewMemberRequest(_ context.Context, r *http.Request) (interface{}, e
return nil, err
}

name, err := readStringQuery(r, nameKey, defKey)
identity, err := readStringQuery(r, identityKey, defKey)
if err != nil {
return nil, err
}

req := viewMemberReq{
token: token,
UserName: name,
token: token,
UserIdentity: identity,
}

return req, nil
Expand Down
6 changes: 3 additions & 3 deletions ui/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ type Service interface {
// UnassignMember removes a member from an organization.
UnassignMember(token, orgID string, req sdk.UsersRelationRequest) error
// View Member retrieves information about the organization Member with the given ID.
ViewMember(token, userName string) ([]byte, error)
ViewMember(token, userIdentity string) ([]byte, error)
}

var _ Service = (*uiService)(nil)
Expand Down Expand Up @@ -1806,9 +1806,9 @@ func (us *uiService) UnassignMember(token, orgID string, req sdk.UsersRelationRe
return us.sdk.RemoveUserFromDomain(orgID, req, token)
}

func (us *uiService) ViewMember(token, userName string) (b []byte, err error) {
func (us *uiService) ViewMember(token, userIdentity string) (b []byte, err error) {
pgm := sdk.PageMetadata{
Name: userName,
Identity: userIdentity,
}
usersPage, err := us.sdk.Users(pgm, token)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion ui/web/template/organization.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ <h2>Organization Members</h2>
<tbody>
{{ range $i, $m := .Members }}
<tr
onclick="location.href='/organizations/members?name={{ $m.Name }}';"
onclick="location.href='/organizations/members?identity={{ $m.Credentials.Identity }}';"
class="clickable-row"
>
<td>{{ $m.Name }}</td>
Expand Down

0 comments on commit ca929c8

Please sign in to comment.