Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Scope as constant inserted.

  • Loading branch information...
commit 84b42d438f7355313c1b0f1b6274217e8ca42a77 1 parent a13236d
lazarm lazarm authored

Showing 1 changed file with 8 additions and 3 deletions. Show diff stats Hide diff stats

  1. +8 3 piplmesh/account/views.py
11 piplmesh/account/views.py
@@ -16,6 +16,9 @@
16 16
17 17 from piplmesh.account import forms, models
18 18
  19 +FACEBOOK_SCOPE = 'email' # You may add additional parameters
  20 +GOOGLE_SCOPE = 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile'
  21 +
19 22 class FacebookLoginView(generic_views.RedirectView):
20 23 """
21 24 This view authenticates the user via Facebook.
@@ -26,7 +29,7 @@ class FacebookLoginView(generic_views.RedirectView):
26 29 def get_redirect_url(self, **kwargs):
27 30 args = {
28 31 'client_id': settings.FACEBOOK_APP_ID,
29   - 'scope': settings.FACEBOOK_SCOPE,
  32 + 'scope': FACEBOOK_SCOPE,
30 33 'redirect_uri': self.request.build_absolute_uri(urlresolvers.reverse('facebook_callback')),
31 34 }
32 35 return "https://www.facebook.com/dialog/oauth?%(args)s" % {'args': urllib.urlencode(args)}
@@ -102,7 +105,7 @@ def get_redirect_url(self, **kwargs):
102 105 'response_type': 'code',
103 106 'client_id': settings.GOOGLE_CLIENT_ID,
104 107 'redirect_uri': self.request.build_absolute_uri(urlresolvers.reverse('google_callback')),
105   - 'scope': settings.GOOGLE_SCOPE,
  108 + 'scope': GOOGLE_SCOPE,
106 109 }
107 110 return "https://accounts.google.com/o/oauth2/auth?%(args)s" % {'args': urllib.urlencode(args)}
108 111
@@ -118,10 +121,12 @@ class GoogleCallbackView(generic_views.RedirectView):
118 121 def get(self, request, *args, **kwargs):
119 122 if 'code' in request.GET:
120 123 user = auth.authenticate(google_token=request.GET['code'], request=request)
121   - assert user.is_authenticated()
  124 + assert user.is_authenticated()
122 125 auth.login(request, user)
123 126 return super(GoogleCallbackView, self).get(request, *args, **kwargs)
124 127 else:
  128 + # TODO: Message user that they have not been logged in because they cancelled the google app
  129 + # TODO: Use information provided from google as to why the login was not successful
125 130 return super(GoogleCallbackView, self).get(request, *args, **kwargs)
126 131
127 132

0 comments on commit 84b42d4

Please sign in to comment.
Something went wrong with that request. Please try again.