Skip to content

Commit

Permalink
[liboauth] Show error message after Aouth login failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Gehl authored and romainr committed Mar 13, 2014
1 parent 5cee8ea commit 7307bf6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions desktop/libs/liboauth/src/liboauth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@


@login_notrequired
def show_login_page(request):
def show_login_page(request, login_errors=False):
"""Used by the non-jframe login"""
redirect_to = request.REQUEST.get('next', '/')
is_first_login_ever = OAuthBackend.is_first_login_ever()
Expand All @@ -56,7 +56,7 @@ def show_login_page(request):
'action': urlresolvers.reverse('oauth_login'),
'next': redirect_to,
'first_login_ever': is_first_login_ever,
'login_errors': request.method == 'POST',
'login_errors': request.method == 'POST' or login_errors,
'socialGoogle': liboauth.conf.CONSUMER_KEY_GOOGLE.get() != "" and liboauth.conf.CONSUMER_SECRET_GOOGLE.get() != "",
'socialFacebook': liboauth.conf.CONSUMER_KEY_FACEBOOK.get() != "" and liboauth.conf.CONSUMER_SECRET_FACEBOOK.get() != "",
'socialLinkedin': liboauth.conf.CONSUMER_KEY_LINKEDIN.get() != "" and liboauth.conf.CONSUMER_SECRET_LINKEDIN.get() != "",
Expand All @@ -81,8 +81,7 @@ def oauth_authenticated(request):

access_token = OAuthBackend.handleAuthenticationRequest(request)
if access_token == "":
login_failed_url = '/'
return HttpResponseRedirect('{loginfailed}'.format(loginfailed = login_failed_url))
return show_login_page(request, True)
user = authenticate(access_token = access_token)
login(request, user)
redirect_to = request.REQUEST.get('next', '/')
Expand Down

0 comments on commit 7307bf6

Please sign in to comment.