Skip to content

Commit dc4f742

Browse files
committed
Merge pull request #63 from apinf/feature/github-auth
Feature/GitHub auth
2 parents 48c238b + 76658b6 commit dc4f742

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

.meteor/packages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ notifications
5555
yogiben:admin
5656
timmyg:wow
5757
tsega:skrollr
58+
accounts-github

.meteor/versions

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
accounts-base@1.2.0
22
accounts-facebook@1.0.4
3+
accounts-github@1.0.4
34
accounts-google@1.0.4
45
accounts-oauth@1.1.5
56
accounts-password@1.1.1
@@ -52,6 +53,7 @@ fastclick@1.0.3
5253
favorites@0.0.4
5354
fortawesome:fontawesome@4.3.0
5455
geojson-utils@1.0.3
56+
github@1.1.3
5557
google@1.1.5
5658
handlebars@1.0.3
5759
html-tools@1.0.4

server/accounts.coffee

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
Accounts.onCreateUser (options, user) ->
2-
profileImageUrl = undefined
3-
user.profile = user.profile or {}
2+
profileImageUrl = undefined
3+
user.profile = user.profile or {}
44

5-
if user.services?.facebook
6-
user.emails = [{address: user.services.facebook.email, verified: true}]
7-
user.profile.firstName = user.services.facebook.first_name
8-
user.profile.lastName = user.services.facebook.last_name
9-
if user.services?.google
10-
user.emails = [{address: user.services.google.email, verified: true}]
11-
user.profile.firstName = user.services.google.given_name
12-
user.profile.lastName = user.services.google.family_name
13-
# TODO: twitter email, first name and last name
5+
if user.services?.facebook
6+
user.emails = [{address: user.services.facebook.email, verified: true}]
7+
user.profile.firstName = user.services.facebook.first_name
8+
user.profile.lastName = user.services.facebook.last_name
9+
if user.services?.google
10+
user.emails = [{address: user.services.google.email, verified: true}]
11+
user.profile.firstName = user.services.google.given_name
12+
user.profile.lastName = user.services.google.family_name
13+
if user.services?.github
14+
user.emails = [{address: user.services.github.email, verified: true}]
1415

15-
if user.services?.facebook?.id
16-
profileImageUrl = 'https://graph.facebook.com/v2.3/' + user.services.facebook.id + '/picture?type=normal'
17-
if user.services?.google?.id
18-
profileImageUrl = user.services.google.picture
19-
if user.services?.twitter?.id
20-
profileImageUrl = user.services.twitter.profile_image_url
16+
if user.services?.facebook?.id
17+
profileImageUrl = 'https://graph.facebook.com/v2.3/' + user.services.facebook.id + '/picture?type=normal'
18+
if user.services?.google?.id
19+
profileImageUrl = user.services.google.picture
20+
if user.services?.twitter?.id
21+
profileImageUrl = user.services.twitter.profile_image_url
22+
if user.services?.github?.id
23+
profileImageUrl = user.services.github.avatar_url
2124

22-
if not profileImageUrl
23-
# Try and get via Gravatar
24-
# Gravatar currently always returns an image, whether the user set one or not.
25-
# It's possible to set {default: 404} and then detect a 404 status via HTTP request
26-
# This could increase the time needed to create a new user so it's avoided for now
27-
#
28-
# TODO: Set default profile picture in config. If 'null' then field is left blank
25+
if not profileImageUrl
26+
# Try and get via Gravatar
27+
# Gravatar currently always returns an image, whether the user set one or not.
28+
# It's possible to set {default: 404} and then detect a 404 status via HTTP request
29+
# This could increase the time needed to create a new user so it's avoided for now
30+
#
31+
# TODO: Set default profile picture in config. If 'null' then field is left blank
2932

30-
email = user.emails?[0]?.address or ''
31-
profileImageUrl = Gravatar.imageUrl email, {default: 'identicon'}
33+
email = user.emails?[0]?.address or ''
34+
profileImageUrl = Gravatar.imageUrl email, {default: 'identicon'}
3235

33-
if profileImageUrl
34-
picture = new FS.File()
35-
attachData = Meteor.wrapAsync picture.attachData, picture
36-
attachData profileImageUrl
37-
picture.name('picture ' + user._id + '.png')
38-
profilePicture = ProfilePictures.insert picture
39-
user.profile.picture = profilePicture._id
40-
41-
user
36+
if profileImageUrl
37+
picture = new FS.File()
38+
attachData = Meteor.wrapAsync picture.attachData, picture
39+
attachData profileImageUrl
40+
picture.name('picture ' + user._id + '.png')
41+
profilePicture = ProfilePictures.insert picture
42+
user.profile.picture = profilePicture._id
43+
44+
user

0 commit comments

Comments
 (0)