MCPcopy Index your code
hub / github.com/rilldata/rill / SearchProjectUsers

Method SearchProjectUsers

admin/server/users.go:587–630  ·  view source on GitHub ↗

SearchProjectUsers returns a list of users that match the given search/email query.

(ctx context.Context, req *adminv1.SearchProjectUsersRequest)

Source from the content-addressed store, hash-verified

585
586// SearchProjectUsers returns a list of users that match the given search/email query.
587func (s *Server) SearchProjectUsers(ctx context.Context, req *adminv1.SearchProjectUsersRequest) (*adminv1.SearchProjectUsersResponse, error) {
588 observability.AddRequestAttributes(ctx,
589 attribute.String("args.org", req.Org),
590 attribute.String("args.project", req.Project),
591 attribute.String("args.email_query", req.EmailQuery),
592 )
593
594 proj, err := s.admin.DB.FindProjectByName(ctx, req.Org, req.Project)
595 if err != nil {
596 return nil, err
597 }
598
599 claims := auth.GetClaims(ctx)
600 if !claims.ProjectPermissions(ctx, proj.OrganizationID, proj.ID).ManageProject {
601 return nil, status.Error(codes.PermissionDenied, "not authorized to search project users")
602 }
603
604 token, err := unmarshalPageToken(req.PageToken)
605 if err != nil {
606 return nil, err
607 }
608
609 pageSize := validPageSize(req.PageSize)
610
611 users, err := s.admin.DB.SearchProjectUsers(ctx, proj.ID, req.EmailQuery, token.Val, pageSize)
612 if err != nil {
613 return nil, err
614 }
615
616 nextToken := ""
617 if len(users) >= pageSize {
618 nextToken = marshalPageToken(users[len(users)-1].Email)
619 }
620
621 dtos := make([]*adminv1.User, len(users))
622 for i, user := range users {
623 dtos[i] = s.userToPB(user, false)
624 }
625
626 return &adminv1.SearchProjectUsersResponse{
627 Users: dtos,
628 NextPageToken: nextToken,
629 }, nil
630}
631
632func (s *Server) userToPB(u *database.User, isCurrentUser bool) *adminv1.User {
633 // Compute a HMAC-SHA256 hash of the email if Pylon identity verification is configured.

Callers

nothing calls this directly

Calls 11

userToPBMethod · 0.95
AddRequestAttributesFunction · 0.92
GetClaimsFunction · 0.92
unmarshalPageTokenFunction · 0.85
validPageSizeFunction · 0.85
marshalPageTokenFunction · 0.85
StringMethod · 0.65
FindProjectByNameMethod · 0.65
ProjectPermissionsMethod · 0.65
SearchProjectUsersMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected