Last active
April 24, 2020 18:13
-
-
Save piyushgarg-dev/67f17969f2f02e4e321b7b3ffc3f5b3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const passport = require('passport'); | |
| const session = require('express-session'); | |
| const app = express(); | |
| app.use(session({ secret: 'mysecret', resave: true, saveUninitialized: true })); | |
| app.use(passport.initialize()) | |
| app.use(passport.session()) | |
| app.use(express.json()) | |
| app.get('/', (req, res) => { | |
| if(req.user) { | |
| res.send(`Hey There.... You are ${req.user.email}`) | |
| } | |
| else{ | |
| res.send('Hey.. I dont know who are you??? ') | |
| } | |
| }) | |
| app.post('/login', passport.authenticate('local'), (req, res) => { | |
| res.send('Loggin Sucess') | |
| }) | |
| app.listen(9000, () => console.log(`Server running at 9000`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment