Add user/list endpoint (#280)

* user list

* add paging
This commit is contained in:
Dominic Wong
2021-11-19 12:10:37 +00:00
committed by GitHub
parent d6d7577584
commit c8dca46bab
6 changed files with 359 additions and 100 deletions

View File

@@ -1,6 +1,7 @@
package handler
import (
goctx "context"
"crypto/rand"
"encoding/base64"
"fmt"
@@ -372,3 +373,15 @@ func (s *User) ResetPassword(ctx context.Context, req *pb.ResetPasswordRequest,
return nil
}
func (s *User) List(ctx goctx.Context, request *pb.ListRequest, response *pb.ListResponse) error {
accs, err := s.domain.List(ctx, request.Offset, request.Limit)
if err != nil && err != domain.ErrNotFound {
return errors.InternalServerError("user.List", "Error retrieving user list")
}
response.Users = make([]*pb.Account, len(accs))
for i, v := range accs {
response.Users[i] = v
}
return nil
}