Skip to content

Commit

Permalink
Save token on user login #23
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuscoto committed Jan 31, 2015
1 parent c914161 commit 5e18cc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var md5 = require('MD5');
var Users = mongoose.model('Users');
var Notifications = mongoose.model('Notifications');
var Challenges = mongoose.model('Challenges');
var Tokens = mongoose.model('Tokens');

var nextUserId = 0;
global.usersById = {};
Expand Down Expand Up @@ -78,6 +79,9 @@ exports.login = function(sess, accessToken, accessTokenExtra, ghUser) {

usersByGhId[ghUser.id] = addUser('github', ghUser);

// Save user token
Tokens.update({'token': accessToken}, update, {'upsert': true}).exec()

Users
.findOne({ 'user_id': usersByGhId[ghUser.id].github.id },
'user_name', function (err, user) {
Expand Down
1 change: 1 addition & 0 deletions model/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ mongoose.model('Users', Users)
mongoose.model('Notifications', Notifications)
mongoose.model('Challenges', Challenges)
mongoose.model('Pulls', Pulls)
mongoose.model('Tokens', Tokens)

mongoose.connect('mongodb://localhost/rosedu-challenge')

0 comments on commit 5e18cc2

Please sign in to comment.