diff --git a/.gitignore b/.gitignore index cae0190..e72e7f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ .idea -package-lock.json \ No newline at end of file +package-lock.json +.env \ No newline at end of file diff --git a/frontend/js/signup.js b/frontend/js/signup.js index cfff648..e6e71df 100644 --- a/frontend/js/signup.js +++ b/frontend/js/signup.js @@ -27,6 +27,8 @@ document.getElementById('signupForm').addEventListener('submit',async function ( return; } + + const response = await fetch ('/auth/signup', { method: 'POST', headers: { diff --git a/index.js b/index.js index 270a807..d81f8ef 100644 --- a/index.js +++ b/index.js @@ -73,8 +73,9 @@ app.post('/auth/changepassword', async (req, res) => { if(!cPassword && nPassword) { return res.json({ message: 'Field is empty' }) } - - console.log(cPassword, nPassword) + if(nPassword === cPassword) { + return res.json({ message: 'Passwords are the same' }) + } let username; try { const decoded = jwt.verify(token, jwtSecret); @@ -88,7 +89,7 @@ app.post('/auth/changepassword', async (req, res) => { const match = await bcrypt.compare(cPassword, result.rows[0].password); // if not return information if(!match){ - return res.json({ message: 'Current password is not valid', success: false }) + return res.json({ message: 'Current password is invalid', success: false }) } // hash password const salt = await bcrypt.genSalt(saltRounds);