Skip to content

Commit

Permalink
fixed passport auth error and added env file
Browse files Browse the repository at this point in the history
  • Loading branch information
leonnoel committed Aug 30, 2022
1 parent 67afe07 commit d65c1c6
Show file tree
Hide file tree
Showing 8 changed files with 1,053 additions and 1,555 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules
.env
.vscode
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"editor.fontSize": 38,
"terminal.integrated.fontSize": 60
"terminal.integrated.fontSize": 42
}
2 changes: 2 additions & 0 deletions config/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PORT = 2121
DB_STRING = mongodb+srv://demo:[email protected]/todos?retryWrites=true&w=majority
4 changes: 3 additions & 1 deletion controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const User = require('../models/User')
}

exports.logout = (req, res) => {
req.logout()
req.logout(() => {
console.log('User has logged out.')
})
req.session.destroy((err) => {
if (err) console.log('Error : Failed to destroy the session during logout.', err)
req.user = null
Expand Down
9 changes: 1 addition & 8 deletions middleware/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ module.exports = {
} else {
res.redirect('/')
}
},
ensureGuest: function (req, res, next) {
if (!req.isAuthenticated()) {
return next()
} else {
res.redirect('/dashboard')
}
},
}
}

Loading

0 comments on commit d65c1c6

Please sign in to comment.