Advertisement
Guest User

Untitled

a guest
Feb 20th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //passport.js
  2.  
  3. passport.use(new BoxStrategy({
  4.     clientID: config.box.boxClientID,
  5.     clientSecret: config.box.boxClientSecret,
  6.     callbackURL: config.box.boxCallbackURL
  7.   },
  8.   function(accessToken, refreshToken, profile, done) {
  9.     // asynchronous verification, for effect...
  10.     process.nextTick(function () {
  11.      
  12.       // To keep the example simple, the user's Box profile is returned to
  13.       // represent the logged-in user.  In a typical application, you would want
  14.       // to associate the Box account with a user record in your database,
  15.       // and return that user instead.
  16.       return done(null, profile);
  17.     });
  18.   }
  19. ));
  20.  
  21. //session.js
  22.  
  23. exports.boxLogin = function(req, res, next) {
  24.   console.log('box auth');
  25.   passport.authenticate('box'), function(req, res) {
  26.     // The request will be redirected to Box for authentication, so this
  27.     // function will not be called.
  28.   }
  29. };
  30.  
  31. exports.boxLoginCallback = function(req, res, next) {
  32.   console.log('box login callback');
  33.   app.get('/auth/box/callback',
  34.   passport.authenticate('box', { failureRedirect: '/login' }),
  35.   function(req, res) {
  36.     res.redirect('/');
  37.   });
  38. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement