in index.js,
const express = require("express")
const mongoose = require("mongoose")
const cors = require("cors")
const CustomerModel = require('./models/Customer')
const app = express()
app.use(express.json())
app.use(cors())
mongoose.connect("mongodb://localhost:27017/customer")
app.post("/login", (req, res) => {
const {email, password} = req.body
CustomerModel.findOne({email: email})
.then(user => {
if(user) {
if(user.password === password) {
res.json("Success")
} else {
res.json("the password is incorrect")
}
} else {
res.json("No record existed")
}
})
})
app.post('/register', (req, res) => {
CustomerModel.create(req.body)
.then(customers => res.json(customers))
.catch(err => res.json(err))
})
app.listen(3001, () => {
console.log("server is running")
})
////////////////
in customer.js,
const mongoose = require("mongoose")
const CustomerSchema = new mongoose.Schema({
name: String,
email: String,
password: String,
})
const CustomerModel = mongoose.model("customer", CustomerSchema)
module.exports = CustomerModel
/////////////////
Help me modify this code so that i could have email verification,
NOTE: i’ve installed nodemailer, crypto, dotenv and all the necessary things for email verification.
please put it some notes as well to modify my front-end on what should i add? I put lots of code so that you could modify it to make the email verificastion happen. So please answer this bcs im learning react and node. BTW this is the backend so as ui mention please add in details if i need to modify my front-end. You could modify it either email verification using OTP or using links.