node.js - Passport JS and restify and Client sessions -


i'm stuck on error passport. building api using restify. using client-session session , passport google oauth 2.

i having trouble @ point serialise user , create session. seem getting no errors printing out large node objects console.

var restify = require('restify'); var massive = require('massive'); var passport = require('passport'); var googlestrategy = require('passport-google-oauth2').strategy; var _ = require('lodash'); var sessions = require("client-sessions");   var app = function(config, done) {  // declare db , server  var server = restify.createserver(),     db;   // set server settings  server.use(restify.bodyparser()); server.pre(restify.pre.sanitizepath()); server.use(restify.queryparser()); server.use(sessions({     // cookie name dictates key name added request object     cookiename: 'skyrail_session',     // should large unguessable string     secret: 'abc123yyighhcggfgucgdguhvgcydtfugjvhfguijkvhgcfgvcfg',     // how long session stay valid in ms     duration: 24 * 60 * 60 * 1000,     activeduration: 1000 * 60 * 5 })); server.use(passport.initialize()); server.use(passport.session());  server.use(function logger(req, res, next) {     console.log(new date(), req.method, req.url);     next(); });  server.on('uncaughtexception', function(request, response, route, error) {     console.error(error.stack);     response.send(error); });     // passport auth settings  passport.use(new googlestrategy({         clientid: id,         clientsecret: secret,         callbackurl: 'http://127.0.0.1:8080/oauth2callback',         passreqtocallback: true     },     function(request, accesstoken, refreshtoken, profile, done) {          var isemail = false;          (var = profile.emails.length - 1; >= 0; i--) {             if (_.endswith(profile.emails[i].value, 'test.co.uk')) {                 isemail = true;             }         };          if (isemail) {             // user stuff             done(null, profile);          } else {              done(null, profile);         }      } ));  passport.serializeuser(function(user, done) {     console.log('serializing user.');      done(null, user.id); });  passport.deserializeuser(function(user, done) {     console.log('deserialize user.');     done(null, user.id); });   // connect database  massive.connect({     connectionstring: config.postgres.constring }, function(err, massiveinstance) {     db = massiveinstance;     done(); });   var google = passport.authenticate('google', {     scope: 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile' });   var googlecallback = passport.authenticate('google');   var authenticate = passport.authenticate('google', {     successredirect: '/success',     failureredirect: '/fail' })   // setup shceduler  var scheduler = require('node-schedule');   // return appropriate method , objects.  return {      server: server,     db: db,     authenticate: authenticate,     google: google,     googlecallback: googlecallback,     scheduler: scheduler }    };    module.exports = app 

it works fine , end @ google accept , when gets point.

passport.serializeuser(function(user, done) {     console.log('serializing user.');      done(null, user.id); }); 

it logs console , starts throwing out node objects. pretty sure has setting cooking.

i @ bit of loss how debug. there not information using passport restify.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -