From 643e38c035c7cc68778b814482bbd3a6470799e2 Mon Sep 17 00:00:00 2001 From: C4illin Date: Mon, 18 Mar 2024 22:35:46 +0100 Subject: [PATCH] format --- Dockerfile | 13 ++++----- backend/index.js | 3 +- frontend/app.js | 74 +++++++++++++++++++++++++---------------------- frontend/app.scss | 32 ++++++++++---------- 4 files changed, 63 insertions(+), 59 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ea96e5..17648d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,18 @@ FROM node:20 -WORKDIR /app/frontend +WORKDIR /app/frontend COPY frontend/package*.json ./ RUN npm install -COPY frontend/ ./ -RUN npm run build - -ENV NODE_ENV=production WORKDIR /app/backend - COPY backend/package*.json ./ RUN npm install --production - COPY backend/ ./ +WORKDIR /app/frontend +COPY frontend/ ./ +RUN npm run build + +WORKDIR /app/backend EXPOSE 3000 CMD ["node", "index.js"] \ No newline at end of file diff --git a/backend/index.js b/backend/index.js index 90a59b6..8c61818 100644 --- a/backend/index.js +++ b/backend/index.js @@ -189,12 +189,13 @@ app.get("/confirm/:token", async (req, res) => { conn = await pool.getConnection(); let sql = "SELECT user_id FROM confirmations WHERE token = ?"; const rows = await conn.query(sql, [token]); - if (rows.length) { + if (rows.length > 0) { // If the token exists, delete it from the database and set the user to active sql = "DELETE FROM confirmations WHERE token = ?"; await conn.query(sql, [token]); sql = "UPDATE users SET active = 1 WHERE id = ?"; await conn.query(sql, [rows[0].user_id]); + console.log(`Token: ${token} has been used to activate an account`) res.send(`Your account has been activated. Redirecting to the home page...