Guest User

Untitled

a guest
Nov 20th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. app.get(
  2. '/auth/trello_provider/callback',
  3. passport.authenticate('trello', { failureRedirect: '/unauth' }),
  4. (req, res) => res.redirect('/')
  5. );
  6.  
  7. const ensureAuthenticatedForApiRequests = (req, res, next) => {
  8. if (req.isAuthenticated()) {
  9. return next();
  10. }
  11.  
  12. return res.status(401).json({
  13. status: 'Unauthorized',
  14. statusCode: 401,
  15. message: 'You are not authorized. Go away!',
  16. });
  17. };
  18.  
  19. app.get(
  20. '/api/contact/:contactId',
  21. ensureAuthenticatedForApiRequests,
  22. (req, res) => {
  23. // ...
  24. }
  25. );
  26.  
  27. app.get('/route', passport.authenticate(['strategy1', 'strategy2'], (req, res) => {
  28. // ...
  29. });
Add Comment
Please, Sign In to add comment