Skip to content

Commit

Permalink
fix: api.v2.user_service.ListUserAccessTokens limit length after sort
Browse files Browse the repository at this point in the history
  • Loading branch information
whatwewant committed Apr 7, 2024
1 parent 210a0ef commit d2e6bb0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions server/route/api/v2/user_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,6 @@ func (s *APIV2Service) ListUserAccessTokens(ctx context.Context, request *apiv2p
return nil, status.Errorf(codes.Internal, "failed to list access tokens: %v", err)
}

// limit only the first 200 access tokens.
if len(userAccessTokens) > 200 {
userAccessTokens = userAccessTokens[:200]
}

accessTokens := []*apiv2pb.UserAccessToken{}
for _, userAccessToken := range userAccessTokens {
claims := &auth.ClaimsMessage{}
Expand Down Expand Up @@ -389,6 +384,12 @@ func (s *APIV2Service) ListUserAccessTokens(ctx context.Context, request *apiv2p
slices.SortFunc(accessTokens, func(i, j *apiv2pb.UserAccessToken) int {
return int(i.IssuedAt.Seconds - j.IssuedAt.Seconds)
})

// limit only the first 200 access tokens.
if len(userAccessTokens) > 200 {
userAccessTokens = userAccessTokens[:200]

Check failure on line 390 in server/route/api/v2/user_service.go

View workflow job for this annotation

GitHub Actions / go-static-checks

SA4006: this value of `userAccessTokens` is never used (staticcheck)
}

response := &apiv2pb.ListUserAccessTokensResponse{
AccessTokens: accessTokens,
}
Expand Down

0 comments on commit d2e6bb0

Please sign in to comment.