fixed crash on wrong login password for existing user, update docker-compose.yaml

This commit is contained in:
slawk0
2024-08-29 19:13:40 +02:00
parent 2ec948c1e3
commit 1c927f75f5
3 changed files with 2 additions and 5 deletions

View File

@@ -31,8 +31,6 @@ USER node
# Copy the rest of the source files into the image.
COPY . .
CMD npm i
# Expose the port that the application listens on.
EXPOSE ${APP_PORT}

View File

@@ -13,7 +13,7 @@ services:
SESSION_SECRET: ${SESSION_SECRET}
JWT_SECRET: ${JWT_SECRET}
ports:
- "3000:3000"
- ${APP_PORT}:${APP_PORT}
depends_on:
- db

View File

@@ -10,10 +10,8 @@ const { initializeSocket } = require('./backend/socket.js');
const bcrypt = require('bcrypt');
const saltRounds = 10;
const { Server } = require('socket.io');
const { createServer } = require('node:http');
const server = createServer(app);
const io = initializeSocket(server);
const jwt = require('jsonwebtoken');
const jwtSecret = process.env.JWT_SECRET;
@@ -163,6 +161,7 @@ async function loginUser(req, res) {
const match = await bcrypt.compare(password, result.rows[0].password);
if (!match) {
res.send('Incorrect Username or Password!');
return;
}
const token = jwt.sign({ username }, jwtSecret, {
expiresIn: '30d' // token expires in 30 days