-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
61 lines (43 loc) · 1.36 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const mongoose = require('mongoose');
const express = require('express');
const ejs = require('ejs');
const app = express();
const jwt = require('jsonwebtoken');
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.set('view engine', 'ejs');
//database connection
mongoose.connect('mongodb://localhost:27017/bloodbank');
const db = mongoose.connection;
db.on('error', ()=> console.log("Error Occured: "));
db.once('open', ()=> console.log("Connected to database "));
// Database Schema //solid value
const user = {
email : "digen@gmail.com"
}
const userSchema = new mongoose.Schema({
email : String
});
const userTable = mongoose.model('students', userSchema)
app.get('/forgot-password', (req, res) => {
userTable.find({}, function(err, data) {
res.render('forgot-password', {
dataList: data
})
})
})
app.post('/forgot-password', (req, res) => {
//Finding Email That Passed By The User In Input Field And Matching With Data Present In Database
userTable.findOne({email : req.body.email}, (err, user) =>{
if(err){
console.log(err);
}
if(user){
console.log("User Already Exists");
}
else{
console.log("User Nor Exists");
}
})
})
app.listen(5000);