fixing TS
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 51m30s
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 51m30s
This commit is contained in:
12
server.ts
12
server.ts
@@ -15,7 +15,7 @@ import * as db from './src/services/db';
|
||||
import { logger } from './src/services/logger'; // This import is correct
|
||||
import * as aiService from './src/services/aiService.server'; // Import the new server-side AI service
|
||||
import { sendPasswordResetEmail } from './src/services/emailService';
|
||||
import { Profile, UserProfile, ShoppingListItem, ReceiptItem } from './src/types';
|
||||
import { UserProfile, ShoppingListItem } from './src/types';
|
||||
|
||||
// Load environment variables from a .env file at the root of your project
|
||||
dotenv.config();
|
||||
@@ -122,7 +122,7 @@ passport.use(new LocalStrategy(
|
||||
}
|
||||
|
||||
// 3. Success! Return the user object (without password_hash for security).
|
||||
const { password_hash, ...userWithoutHash } = user;
|
||||
const { password_hash: _password_hash, ...userWithoutHash } = user;
|
||||
logger.info(`User successfully authenticated: ${email}`);
|
||||
return done(null, userWithoutHash);
|
||||
} catch (err) {
|
||||
@@ -958,8 +958,8 @@ app.post('/api/auth/register', async (req: Request, res: Response, next: NextFun
|
||||
// Login Route
|
||||
app.post('/api/auth/login', (req: Request, res: Response, next: NextFunction) => {
|
||||
// Use passport.authenticate with the 'local' strategy
|
||||
// { session: false } because we're using JWTs, not server-side sessions
|
||||
passport.authenticate('local', { session: false }, (err: Error, user: Express.User | false, info: { message: string }) => {
|
||||
// { session: false } because we're using JWTs, not server-side sessions. The 'info' object is not used, so it's removed.
|
||||
passport.authenticate('local', { session: false }, (err: Error, user: Express.User | false) => {
|
||||
const { rememberMe } = req.body; // Get the 'rememberMe' flag from the request
|
||||
if (err) {
|
||||
logger.error('Login authentication error in /login route:', { error: err });
|
||||
@@ -967,7 +967,7 @@ app.post('/api/auth/login', (req: Request, res: Response, next: NextFunction) =>
|
||||
}
|
||||
if (!user) {
|
||||
// Authentication failed (e.g., incorrect credentials)
|
||||
return res.status(401).json({ message: info ? info.message : 'Login failed' });
|
||||
return res.status(401).json({ message: 'Login failed' });
|
||||
}
|
||||
|
||||
// User is authenticated, create and sign a JWT
|
||||
@@ -1587,7 +1587,7 @@ app.get('/api/receipts/:id/deals', passport.authenticate('jwt', { session: false
|
||||
// --- Error Handling and Server Startup ---
|
||||
|
||||
// Basic error handling middleware
|
||||
app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
|
||||
app.use((err: Error, req: Request, res: Response, _next: NextFunction) => {
|
||||
logger.error('Unhandled application error:', { error: err.stack });
|
||||
res.status(500).send('Something broke!');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user