From cd2378c665ac20dcbdfec9fd15fdf9d2e432981f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 12 Jul 2025 19:12:30 +0200 Subject: [PATCH] fix: add user ID for no-auth mode and improve TypeScript imports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract improvements from PR #318: 1. Set default user ID in no-auth mode for auth middleware - Ensures consistent behavior when authentication is disabled - Prevents potential issues with undefined user IDs 2. Convert to type-only imports in push notification service - Use TypeScript type imports for better tree shaking - Remove .js extensions from imports for consistency - Minor logging improvement for service worker registration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- web/src/client/services/push-notification-service.ts | 10 +++++----- web/src/server/middleware/auth.ts | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/web/src/client/services/push-notification-service.ts b/web/src/client/services/push-notification-service.ts index 9838d289..8742e6c1 100644 --- a/web/src/client/services/push-notification-service.ts +++ b/web/src/client/services/push-notification-service.ts @@ -1,9 +1,9 @@ -import { PushNotificationPreferences, PushSubscription } from '../../shared/types.js'; -import { createLogger } from '../utils/logger.js'; -import { authClient } from './auth-client.js'; +import type { PushNotificationPreferences, PushSubscription } from '../../shared/types'; +import { createLogger } from '../utils/logger'; +import { authClient } from './auth-client'; // Re-export types for components -export { PushSubscription, PushNotificationPreferences }; +export type { PushSubscription, PushNotificationPreferences }; export type NotificationPreferences = PushNotificationPreferences; const logger = createLogger('push-notification-service'); @@ -71,7 +71,7 @@ export class PushNotificationService { scope: '/', }); - logger.log('service worker registered'); + logger.log('service worker registered successfully'); // Wait for service worker to be ready await navigator.serviceWorker.ready; diff --git a/web/src/server/middleware/auth.ts b/web/src/server/middleware/auth.ts index 7d87efd3..de984be1 100644 --- a/web/src/server/middleware/auth.ts +++ b/web/src/server/middleware/auth.ts @@ -58,9 +58,10 @@ export function createAuthMiddleware(config: AuthConfig) { return next(); } - // If no auth is disabled, allow all requests + // If no auth is required, allow all requests if (config.noAuth) { req.authMethod = 'no-auth'; + req.userId = 'no-auth-user'; // Set a default user ID for no-auth mode return next(); }