Skip to content

Instantly share code, notes, and snippets.

@nanha
Created March 3, 2013 00:25
Show Gist options
  • Save nanha/5073900 to your computer and use it in GitHub Desktop.
Save nanha/5073900 to your computer and use it in GitHub Desktop.
passport qa
안녕하세요.
네 req.isAuthenticated() 함수를 사용하시면 됩니다.
위와 같이 작업하셔도 되고요. middleware 개념으로 작업을 하자면 아래와 같이도 구현할 수 있습니다.
app.get('/account', ensureAuthenticated, function(req, res){
res.render('account', { user: req.user });
});
function ensureAuthenticated(req, res, next) {
if (req.isAuthenticated()) { return next(); }
res.redirect('/login')
}
문의점 있으시면 말씀해주시고, 수고하세요.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment