Skip to content

Commit b517654

Browse files
committed
Render authentication error in case of state issue (closes pennersr#583)
1 parent ff993d1 commit b517654

File tree

1 file changed

+3
-2
lines changed
  • allauth/socialaccount/providers/oauth2

1 file changed

+3
-2
lines changed

allauth/socialaccount/providers/oauth2/views.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from datetime import timedelta
44

5+
from django.core.exceptions import PermissionDenied
56
from django.core.urlresolvers import reverse
67
from django.http import HttpResponseRedirect
78
from django.utils import timezone
@@ -83,7 +84,7 @@ def dispatch(self, request):
8384

8485
class OAuth2CallbackView(OAuth2View):
8586
def dispatch(self, request):
86-
if 'error' in request.GET or not 'code' in request.GET:
87+
if 'error' in request.GET or 'code' not in request.GET:
8788
# TODO: Distinguish cancel from error
8889
return render_authentication_error(request)
8990
app = self.adapter.get_provider().get_app(self.request)
@@ -106,5 +107,5 @@ def dispatch(self, request):
106107
else:
107108
login.state = SocialLogin.unstash_state(request)
108109
return complete_social_login(request, login)
109-
except OAuth2Error:
110+
except (OAuth2Error, PermissionDenied):
110111
return render_authentication_error(request)

0 commit comments

Comments
 (0)