Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';


var mongoose = require('mongoose');
mongoose.connect(process.env.MONGODB_URI);
var {web, rtm} = require('./bot');
var {User, Reminder, Meeting} = require('./models');
var {User, Reminder, Meeting} = require('./models');

//extras

Expand All @@ -25,18 +24,10 @@ app.use(bodyParser.urlencoded({extended: false}));
//google

var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
function getGoogleAuth() {
return new OAuth2(
process.env.GOOGLE_CLIENT_ID,
process.env.GOOGLE_CLIENT_SECRET,
process.env.DOMAIN + '/connect/callback'
);
}

// functions

var {clearState, taskPath} = require('./functions.js');
var {clearState, taskPath, meetingPath, getGoogleAuth} = require('./functions.js');

app.get('/connect', function(req, res){
var userId = req.query.auth_id;
Expand Down Expand Up @@ -90,7 +81,9 @@ app.get('/connect/callback', function(req, res){
return User.findById(req.query.state);
})
.then(function(mongoUser) {
console.log("CHECK googleUser IN APP.JS", googleUser);
mongoUser.googleAccount = tokens;
mongoUser.googleAccount.email = googleUser.emails[0].value;
mongoUser.googleAccount.profile_ID = googleUser.id;
mongoUser.googleAccount.profile_name = googleUser.displayName;
return mongoUser.save();
Expand Down
Loading