Skip to content

Commit

Permalink
fixed bug with redirects on django connect
Browse files Browse the repository at this point in the history
  • Loading branch information
tschellenbach committed May 10, 2012
1 parent 689cd9c commit 9570dce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions django_facebook/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.utils.functional import wraps

import logging
from django_facebook.api import require_persistent_graph
from django_facebook.api import require_persistent_graph, get_persistent_graph
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -60,6 +60,8 @@ def facebook_required_lazy(view_func=None,
redirecting to the log-in page if necessary.
Based on exceptions instead of a check up front
Faster, but more prone to bugs
Use this in combination with require_persistent_graph
"""
from django_facebook.utils import test_permissions
from open_facebook import exceptions as open_facebook_exceptions
Expand All @@ -73,7 +75,9 @@ def _wrapped_view(request, *args, **kwargs):
try:
# call get persistent graph and convert the
# token with correct redirect uri
require_persistent_graph(request, redirect_uri=redirect_uri)
get_persistent_graph(request, redirect_uri=redirect_uri)
#Note we're not requiring a persistent graph here
#You should require a persistent graph in the url when you start using this
return view_func(request, *args, **kwargs)
except open_facebook_exceptions.OpenFacebookException, e:
permission_granted = test_permissions(request, scope_list, redirect_uri)
Expand Down
2 changes: 1 addition & 1 deletion django_facebook/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def connect(request):
'and ensure the context processor is enabled'
facebook_login = bool(int(request.REQUEST.get('facebook_login', 0)))


if facebook_login:
require_persistent_graph(request)
logger.info('trying to connect using facebook')
graph = get_persistent_graph(request)
if graph:
Expand Down

0 comments on commit 9570dce

Please sign in to comment.