This commit is contained in:
2025-08-22 19:37:49 -04:00
parent 93831d4fad
commit c85812ddb6
2 changed files with 31 additions and 3 deletions

View File

@ -144,8 +144,25 @@ func (s *tokenService) CreateStaticToken(ctx context.Context, req *domain.Create
func (s *tokenService) ListByApp(ctx context.Context, appID string, limit, offset int) ([]*domain.StaticToken, error) {
s.logger.Debug("Listing tokens for application", zap.String("app_id", appID))
// TODO: Implement actual token listing
return []*domain.StaticToken{}, nil
tokens, err := s.tokenRepo.GetByAppID(ctx, appID)
if err != nil {
s.logger.Error("Failed to list tokens from repository", zap.Error(err), zap.String("app_id", appID))
return nil, fmt.Errorf("failed to list tokens: %w", err)
}
// Apply pagination manually since GetByAppID doesn't support it
start := offset
end := offset + limit
if start > len(tokens) {
tokens = []*domain.StaticToken{}
} else if end > len(tokens) {
tokens = tokens[start:]
} else {
tokens = tokens[start:end]
}
s.logger.Debug("Listed tokens successfully", zap.String("app_id", appID), zap.Int("count", len(tokens)))
return tokens, nil
}
// Delete deletes a token

View File

@ -131,11 +131,21 @@ const Tokens: React.FC = () => {
console.log('Form values:', values);
console.log('App ID:', values.app_id);
if (!values.app_id) {
// More robust validation for app_id
if (!values.app_id || values.app_id === 'undefined' || values.app_id === undefined) {
console.error('Invalid app_id detected:', values.app_id);
message.error('Please select an application');
return;
}
// Validate that the app_id exists in our applications list
const selectedApp = applications.find(app => app.app_id === values.app_id);
if (!selectedApp) {
console.error('Selected app_id not found in applications list:', values.app_id);
message.error('Selected application is not valid. Please refresh and try again.');
return;
}
const requestData: CreateTokenRequest = {
owner: {
type: values.owner_type,
@ -149,6 +159,7 @@ const Tokens: React.FC = () => {
console.log('Request data:', requestData);
const response = await apiService.createToken(values.app_id, requestData);
console.log('Token creation response:', response);
setNewTokenResponse(response);
message.success('Token created successfully');
loadApplications();