From a8772f7da8a6a57dc691baa0c9a1278f20efdc49 Mon Sep 17 00:00:00 2001 From: prajwal2431 Date: Wed, 1 Jan 2025 12:15:48 +0530 Subject: [PATCH 1/2] Fix issue #428: Otp column missing issue resolved --- config/dbQuery.sql | 3 ++- login-system/otp.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/dbQuery.sql b/config/dbQuery.sql index 249104c..df33e16 100644 --- a/config/dbQuery.sql +++ b/config/dbQuery.sql @@ -14,7 +14,8 @@ CREATE TABLE user_table ( userid INT AUTO_INCREMENT UNIQUE PRIMARY KEY, username VARCHAR(60) NOT NULL, email VARCHAR(80) NOT NULL UNIQUE, - password VARCHAR(140) NOT NULL UNIQUE + password VARCHAR(140) NOT NULL UNIQUE, + otp VARCHAR(6) -- Add the otp column to store OTP values ); -- Create the info_table diff --git a/login-system/otp.js b/login-system/otp.js index 9a63a30..2ff5639 100644 --- a/login-system/otp.js +++ b/login-system/otp.js @@ -26,6 +26,7 @@ const sendOtp = async (req, res) => { let connection; try { connection = await connectToDB(); + console.log("Connected to the database"); // Search for the user in the database const sqlSearch = "SELECT * FROM user_table WHERE email = ?"; @@ -43,7 +44,7 @@ const sendOtp = async (req, res) => { await connection.query(otpQuery, [verifyCode, email]); // Send OTP via notification (could be an email or any other method) - // notify(req, res, email, "Email Verification", `This is your OTP to verify your email: ${verifyCode}`); + notify(req, res, email, "Email Verification", `This is your OTP to verify your email: ${verifyCode}`); return res.send({ message: "OTP sent successfully" }); From 3215fa23a9971a5954d1b2b1ba75ba61685c2f17 Mon Sep 17 00:00:00 2001 From: prajwal2431 Date: Thu, 2 Jan 2025 18:55:38 +0530 Subject: [PATCH 2/2] Insert Query issue resolved --- config/dbQuery.sql | 2 +- login-system/login.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/dbQuery.sql b/config/dbQuery.sql index df33e16..3a9ed01 100644 --- a/config/dbQuery.sql +++ b/config/dbQuery.sql @@ -15,7 +15,7 @@ CREATE TABLE user_table ( username VARCHAR(60) NOT NULL, email VARCHAR(80) NOT NULL UNIQUE, password VARCHAR(140) NOT NULL UNIQUE, - otp VARCHAR(6) -- Add the otp column to store OTP values + otp VARCHAR(6) DEFAULT NULL-- Add the otp column to store OTP values ); -- Create the info_table diff --git a/login-system/login.js b/login-system/login.js index f53b5c7..2656f52 100644 --- a/login-system/login.js +++ b/login-system/login.js @@ -50,7 +50,7 @@ const signup = async (req, res) => { return res.status(409).send('Username Already in Use'); } } else { - const sqlInsert = 'INSERT INTO user_table VALUES (0, ?, ?, ?)'; + const sqlInsert = 'INSERT INTO user_table VALUES (0, ?, ?, ?, null)'; await connection.query(sqlInsert, [username, email, hashpassword]); console.log('Created a new User'); const sub = 'Signup-Research Nexas';