You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2020/02/11 20:01:32 UTC
[airavata-django-portal] 01/02: AIRAVATA-3294 Check authenticate
result before calling login
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit 0f95e9a74128e54c44331464955a79ba65137d91
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Tue Feb 11 15:00:46 2020 -0500
AIRAVATA-3294 Check authenticate result before calling login
If authenticate fails to produce a user, don't try to login in since
that will fail too and produce a spurious error.
---
django_airavata/apps/auth/views.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/django_airavata/apps/auth/views.py b/django_airavata/apps/auth/views.py
index 47fddb9..4c715cb 100644
--- a/django_airavata/apps/auth/views.py
+++ b/django_airavata/apps/auth/views.py
@@ -116,11 +116,14 @@ def callback(request):
try:
login_desktop = request.GET.get('login_desktop', "false") == "true"
user = authenticate(request=request)
- login(request, user)
- if login_desktop:
- return _create_login_desktop_success_response(request)
- next_url = request.GET.get('next', settings.LOGIN_REDIRECT_URL)
- return redirect(next_url)
+ if user is not None:
+ login(request, user)
+ if login_desktop:
+ return _create_login_desktop_success_response(request)
+ next_url = request.GET.get('next', settings.LOGIN_REDIRECT_URL)
+ return redirect(next_url)
+ else:
+ raise Exception("Failed to authenticate user")
except Exception as err:
logger.exception("An error occurred while processing OAuth2 "
"callback: {}".format(request.build_absolute_uri()))