Académique Documents
Professionnel Documents
Culture Documents
Exercise-8
18BCE0557 KUSHAL
Working:
I have made use of jwt and cookies here. When the user visits signup page the user is
welcomed with a form where when form is submitted then user is redirected back to the home
page and cookie is setup which is his jwt, at now jwt and cookie is used by user id is not used
because of the time constraint.
And in signin- if cookie is still there then do nothing and redirect to home page else create a
cookie with jwt and then redirect. In get request of signin if cookie is present then redirect
immediately to home page. I should be using middleware here but at now it’s done in the apis
itself.
Server is up
Database is up:
User Model
Index.js
ongoose = require('./db/mongoose')
const m
const U ser = require('./models/user')
const jwt = require('jsonwebtoken');
})
app.listen(3000, () => {
console.log('Server is up and running!')
})
Signup:
DB: