UNPKG

kpiplus

Version:

KPI+

1 lines 1.01 kB
var User=require("../models/user"),log=require("../models/log"),googleconfig=require("../configs").google,GoogleStrategy=require("passport-google-oauth").OAuth2Strategy,underscore=require("underscore");module.exports=function(e,o){o.serializeUser(function(e,o){o(null,e.id)}),o.deserializeUser(function(e,o){User.findById(e,function(e,r){o(e,r)})}),o.use(new GoogleStrategy({clientID:googleconfig.clientID,clientSecret:googleconfig.clientSecret,callbackURL:googleconfig.callbackURL},function(e,o,r,l){process.nextTick(function(){user=new User;var i={access_token:e,refresh_token:o,email:r.emails[0].value};return user.google.token=JSON.stringify(i),user.google.email=r.emails[0].value,user.google.name=r.displayName,user.google.refreshToken=o,l(null,user)})})),e.get("/auth/google_drive",o.authenticate("google",{scope:["https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/userinfo.email","https://www.googleapis.com/auth/drive"],accessType:"offline",approvalPrompt:"force"}))};