Permalink
Browse files

Scope as constant inserted.

  • Loading branch information...
1 parent a13236d commit 84b42d438f7355313c1b0f1b6274217e8ca42a77 @lazarm lazarm committed May 27, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 piplmesh/account/views.py
View
@@ -16,6 +16,9 @@
from piplmesh.account import forms, models
+FACEBOOK_SCOPE = 'email' # You may add additional parameters
+GOOGLE_SCOPE = 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile'
+
class FacebookLoginView(generic_views.RedirectView):
"""
This view authenticates the user via Facebook.
@@ -26,7 +29,7 @@ class FacebookLoginView(generic_views.RedirectView):
def get_redirect_url(self, **kwargs):
args = {
'client_id': settings.FACEBOOK_APP_ID,
- 'scope': settings.FACEBOOK_SCOPE,
+ 'scope': FACEBOOK_SCOPE,
'redirect_uri': self.request.build_absolute_uri(urlresolvers.reverse('facebook_callback')),
}
return "https://www.facebook.com/dialog/oauth?%(args)s" % {'args': urllib.urlencode(args)}
@@ -102,7 +105,7 @@ def get_redirect_url(self, **kwargs):
'response_type': 'code',
'client_id': settings.GOOGLE_CLIENT_ID,
'redirect_uri': self.request.build_absolute_uri(urlresolvers.reverse('google_callback')),
- 'scope': settings.GOOGLE_SCOPE,
+ 'scope': GOOGLE_SCOPE,
}
return "https://accounts.google.com/o/oauth2/auth?%(args)s" % {'args': urllib.urlencode(args)}
@@ -118,10 +121,12 @@ class GoogleCallbackView(generic_views.RedirectView):
def get(self, request, *args, **kwargs):
if 'code' in request.GET:
user = auth.authenticate(google_token=request.GET['code'], request=request)
- assert user.is_authenticated()
+ assert user.is_authenticated()
auth.login(request, user)
return super(GoogleCallbackView, self).get(request, *args, **kwargs)
else:
+ # TODO: Message user that they have not been logged in because they cancelled the google app
+ # TODO: Use information provided from google as to why the login was not successful
return super(GoogleCallbackView, self).get(request, *args, **kwargs)

0 comments on commit 84b42d4

Please sign in to comment.