-
This commit is contained in:
@ -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) {
|
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))
|
s.logger.Debug("Listing tokens for application", zap.String("app_id", appID))
|
||||||
|
|
||||||
// TODO: Implement actual token listing
|
tokens, err := s.tokenRepo.GetByAppID(ctx, appID)
|
||||||
return []*domain.StaticToken{}, nil
|
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
|
// Delete deletes a token
|
||||||
|
|||||||
@ -131,11 +131,21 @@ const Tokens: React.FC = () => {
|
|||||||
console.log('Form values:', values);
|
console.log('Form values:', values);
|
||||||
console.log('App ID:', values.app_id);
|
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');
|
message.error('Please select an application');
|
||||||
return;
|
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 = {
|
const requestData: CreateTokenRequest = {
|
||||||
owner: {
|
owner: {
|
||||||
type: values.owner_type,
|
type: values.owner_type,
|
||||||
@ -149,6 +159,7 @@ const Tokens: React.FC = () => {
|
|||||||
console.log('Request data:', requestData);
|
console.log('Request data:', requestData);
|
||||||
|
|
||||||
const response = await apiService.createToken(values.app_id, requestData);
|
const response = await apiService.createToken(values.app_id, requestData);
|
||||||
|
console.log('Token creation response:', response);
|
||||||
setNewTokenResponse(response);
|
setNewTokenResponse(response);
|
||||||
message.success('Token created successfully');
|
message.success('Token created successfully');
|
||||||
loadApplications();
|
loadApplications();
|
||||||
|
|||||||
Reference in New Issue
Block a user