Advertisement
Guest User

Untitled

a guest
Nov 6th, 2016
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. www
  2. +-foo
  3. | +-index.html
  4. +-bar
  5. | +-index.html
  6. +-index.html
  7. +-denied.html
  8.  
  9. passport.use(new Strategy(
  10. function(username, password, cb) {
  11.  
  12. data = {};
  13. console.log(username);
  14. console.log(password);
  15. data.username = username;
  16. data.password = password;
  17.  
  18.  
  19. apiRequest.checkLogin(data, cb);
  20. }));
  21.  
  22. app.post('/auth', passport.authenticate('local', {
  23. successRedirect: '/first',
  24. failureRedirect: '/denied.html',
  25. failureFlash: true })
  26. );
  27.  
  28. app.get('/first',function (req, res) {
  29. if (req.isAuthenticated()) {
  30. res.redirect('/foo');
  31. return;
  32. }
  33.  
  34. res.redirect('/denied.html');
  35.  
  36. });
  37.  
  38. app.get('/bar',function (req, res) {
  39. console.log('test here');
  40. if (req.isAuthenticated()) {
  41. res.redirect('/bar');
  42. return;
  43. }
  44.  
  45. res.redirect('/denied.html');
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement