diff --git a/src/index.ts b/src/index.ts index d3307f4..539d219 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,7 @@ import BotClient from './services/Client'; import { ALLOWED_ORIGINS, PORT, RATE_LIMIT_WINDOW_MS, RATE_LIMIT_MAX } from './config'; import rateLimit from 'express-rate-limit'; import authenticateApiKey from './middlewares/verifyApiKey'; +import { authenticateToken } from './middlewares/auth'; import status from './routes/status'; import authRoutes from './routes/auth'; import todosRoutes from './routes/todos'; @@ -94,7 +95,7 @@ app.use(async (req, res, next) => { app.use('/api/auth', authRoutes); app.use('/api/todos', todosRoutes); app.use('/api/user/api-keys', apiKeysRoutes); -app.use('/api/reminders', authenticateApiKey, remindersRoutes); +app.use('/api/reminders', authenticateToken, remindersRoutes); app.use('/api', voteWebhookRoutes); app.use('/api/status', authenticateApiKey, status(bot)); diff --git a/src/middlewares/auth.ts b/src/middlewares/auth.ts index b1fe337..a58e4ac 100644 --- a/src/middlewares/auth.ts +++ b/src/middlewares/auth.ts @@ -2,7 +2,7 @@ import { Request, Response, NextFunction } from 'express'; import jwt from 'jsonwebtoken'; import logger from '../utils/logger'; -const JWT_SECRET = process.env.JWT_SECRET || 'your-jwt-secret'; +const JWT_SECRET = process.env.JWT_SECRET; interface JwtPayload { userId: string; @@ -22,7 +22,7 @@ export const authenticateToken = (req: Request, res: Response, next: NextFunctio } try { - const decoded = jwt.verify(token, JWT_SECRET) as JwtPayload; + const decoded = jwt.verify(token, JWT_SECRET!) as JwtPayload; req.user = decoded; next(); } catch (error) {