From ca929c8dfc1afe640c316429b011ee345bd8b02c Mon Sep 17 00:00:00 2001 From: ianmuchyri Date: Thu, 30 Nov 2023 15:04:37 +0300 Subject: [PATCH] update view user with identity from name Signed-off-by: ianmuchyri --- ui/api/endpoint.go | 2 +- ui/api/logging.go | 6 +++--- ui/api/metrics.go | 4 ++-- ui/api/requests.go | 6 +++--- ui/api/transport.go | 7 ++++--- ui/service.go | 6 +++--- ui/web/template/organization.html | 2 +- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ui/api/endpoint.go b/ui/api/endpoint.go index de1b4e4b..b0cb2da9 100644 --- a/ui/api/endpoint.go +++ b/ui/api/endpoint.go @@ -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 } diff --git a/ui/api/logging.go b/ui/api/logging.go index ea4887f5..1ec65f90 100644 --- a/ui/api/logging.go +++ b/ui/api/logging.go @@ -1158,9 +1158,9 @@ 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 @@ -1168,5 +1168,5 @@ func (lm *loggingMiddleware) ViewMember(token, id string) (b []byte, err error) lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ViewMember(token, id) + return lm.svc.ViewMember(token, identity) } diff --git a/ui/api/metrics.go b/ui/api/metrics.go index 1163971b..397f3cbf 100644 --- a/ui/api/metrics.go +++ b/ui/api/metrics.go @@ -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) } diff --git a/ui/api/requests.go b/ui/api/requests.go index de52b685..dd64f738 100644 --- a/ui/api/requests.go +++ b/ui/api/requests.go @@ -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 diff --git a/ui/api/transport.go b/ui/api/transport.go index 1a98a14e..c9a430ef 100644 --- a/ui/api/transport.go +++ b/ui/api/transport.go @@ -42,6 +42,7 @@ const ( relationKey = "relation" organizationKey = "organization" permissionKey = "permission" + identityKey = "identity" defPage = 1 defLimit = 10 defKey = "" @@ -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 diff --git a/ui/service.go b/ui/service.go index b46f99ab..f72bacc1 100644 --- a/ui/service.go +++ b/ui/service.go @@ -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) @@ -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 { diff --git a/ui/web/template/organization.html b/ui/web/template/organization.html index 4b6721c9..379f0d88 100644 --- a/ui/web/template/organization.html +++ b/ui/web/template/organization.html @@ -187,7 +187,7 @@

Organization Members

{{ range $i, $m := .Members }} {{ $m.Name }}