Permalink
Browse files

support for FACEBOOK_LOGIN_DEFAULT_REDIRECT

  • Loading branch information...
1 parent e6ab5c6 commit 9a6a6591bf4aacc7590f8b764929addb6a75c9d5 @tschellenbach committed May 16, 2012
Showing with 8 additions and 3 deletions.
  1. +2 −2 django_facebook/settings.py
  2. +5 −1 django_facebook/views.py
  3. +1 −0 facebook_example/settings.py
@@ -49,5 +49,5 @@
default_registration_backend = 'django_facebook.registration_backends.FacebookRegistrationBackend'
FACEBOOK_REGISTRATION_BACKEND = getattr(settings, 'FACEBOOK_REGISTRATION_BACKEND', default_registration_backend)
-
-
+#Fall back redirect location when no other location was found
+FACEBOOK_LOGIN_DEFAULT_REDIRECT = getattr(settings, 'FACEBOOK_LOGIN_DEFAULT_REDIRECT', '/')
@@ -97,6 +97,7 @@ def connect(request):
action, user = connect_user(request)
logger.info('Django facebook performed action: %s', action)
except facebook_exceptions.IncompleteProfileError, e:
+ #show them a registration form to add additional data
warn_message = u'Incomplete profile data encountered '\
u'with error %s' % e.message.decode('utf-8', 'replace')
send_warning(warn_message, e=e,
@@ -110,9 +111,11 @@ def connect(request):
)
if action is CONNECT_ACTIONS.CONNECT:
+ #connect means an existing account was attached to facebook
messages.info(request, _("You have connected your account "
"to %s's facebook profile") % facebook_data['name'])
elif action is CONNECT_ACTIONS.REGISTER:
+ #hook for tying in specific post registration functionality
response = backend.post_registration_redirect(request, user)
return response
else:
@@ -124,7 +127,8 @@ def connect(request):
'raising an error')
raise OpenFacebookException('please authenticate')
- return next_redirect(request)
+ #for CONNECT and LOGIN we simple redirect to the next page
+ return next_redirect(request, default=facebook_settings.FACEBOOK_LOGIN_DEFAULT_REDIRECT)
if not settings.DEBUG and facebook_settings.FACEBOOK_HIDE_CONNECT_TEST:
raise Http404
@@ -131,6 +131,7 @@
FACEBOOK_APP_SECRET = '0aceba27823a9dfefa955f76949fa4b4'
FACEBOOK_STORE_LIKES = True
FACEBOOK_STORE_FRIENDS = True
+FACEBOOK_LOGIN_DEFAULT_REDIRECT = '/facebook/connect/'
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend', 'django_facebook.auth_backends.FacebookBackend',)
AUTH_PROFILE_MODULE = 'member.UserProfile'

0 comments on commit 9a6a659

Please sign in to comment.