Add nodemailer configuration and console.log statement
Update formAJAX function to log data from the server Add getUserByEmail and checkEmail functions Update profile.ejs to require login Update addSensorData function to emit new sensor data Update api.css with styling changes Update token route to generate and send token email Update authChecker middleware to allow user and token routes
This commit is contained in:
@ -20,6 +20,16 @@ async function getUserByID(userid) {
|
||||
return userRes;
|
||||
}
|
||||
|
||||
async function getUserByEmail(email) {
|
||||
let userRes = await userModel.findOne({
|
||||
where: {
|
||||
email: email,
|
||||
},
|
||||
});
|
||||
if (!userRes) return false;
|
||||
return userRes;
|
||||
}
|
||||
|
||||
//api/v0/auth/register
|
||||
/* Registering new user
|
||||
1) req.body is taken from html form or wtv
|
||||
@ -131,9 +141,23 @@ async function updateProfile(user, body) {
|
||||
}
|
||||
}
|
||||
|
||||
async function checkEmail(email) {
|
||||
let emailRes = await userModel.findOne({
|
||||
where: {
|
||||
email: email,
|
||||
},
|
||||
});
|
||||
if (!emailRes) return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
getUserByID,
|
||||
getUserByEmail,
|
||||
addUser,
|
||||
loginUser,
|
||||
updateProfile,
|
||||
checkEmail
|
||||
};
|
Reference in New Issue
Block a user