/auth.go Secret
Created
October 27, 2023 14:53
gapi/auth.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (server *Server) GetUsers(ctx context.Context, req *pb.UsersListRequest) (*pb.ListUserMessage, error) { | |
payload, ok := ctx.Value(payloadHeader).(*token.Payload) | |
if !ok { | |
return nil, status.Errorf(codes.Internal, "missing required token") | |
} | |
users, err := auth.GetUsers(server.dbCollection.Users, context.TODO(), int(req.GetPageNumber()), int(req.GetPageSize()), req.Name, payload.Username) | |
if err != nil { | |
return nil, status.Errorf(codes.Internal, err.Error()) | |
} | |
pbUsers := []*pb.User{} | |
for _, user := range users { | |
pbUser := auth.ConvertUserObjectToUser(user) | |
pbUsers = append(pbUsers, pbUser) | |
} | |
return &pb.ListUserMessage{ | |
TotalCount: int32(len(pbUsers)), | |
Users: pbUsers, | |
}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment