diff --git a/config/dbQuery.sql b/config/dbQuery.sql index 249104c..3a9ed01 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) 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'; 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" });