-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathauth.js
30 lines (27 loc) · 815 Bytes
/
auth.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var mongoose = require('mongoose'),
User = mongoose.model('User');
exports.twitter = function(token, tokenSecret, profile, done) {
User.findOrCreate({
username: profile.username,
avatar: profile._json.profile_image_url_https,
link: 'http://twitter.com/' + profile.username,
red: 'twitter',
redId: profile._json.id_str,
token: token,
tokenSecret: tokenSecret
}, done);
};
exports.facebook = function(accessToken, refreshToken, profile, done) {
User.findOrCreate({
username: profile.username,
avatar: 'https://graph.facebook.com/'+profile.username+'/picture',
link: profile.profileUrl,
red: 'facebook',
redId: profile.id,
token: accessToken,
tokenSecret: refreshToken
}, done);
};
exports.user = function(id, done) {
User.findById(id, done);
};