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 2019/06/06 13:56:21 UTC
[airavata-django-portal] branch master updated: AIRAVATA-3063 Log
and display error when username checking fails
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
The following commit(s) were added to refs/heads/master by this push:
new 935b2ba AIRAVATA-3063 Log and display error when username checking fails
935b2ba is described below
commit 935b2ba19aea573c872d688e49cea16692294f10
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Thu Jun 6 09:56:03 2019 -0400
AIRAVATA-3063 Log and display error when username checking fails
---
django_airavata/apps/auth/forms.py | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/django_airavata/apps/auth/forms.py b/django_airavata/apps/auth/forms.py
index f78dd84..374c098 100644
--- a/django_airavata/apps/auth/forms.py
+++ b/django_airavata/apps/auth/forms.py
@@ -1,8 +1,12 @@
+import logging
+
from django import forms
from django.core import validators
from . import iam_admin_client
+logger = logging.getLogger(__name__)
+
USERNAME_VALIDATOR = validators.RegexValidator(
regex=r"^[a-z0-9_-]+$",
message="Username can only contain lowercase letters, numbers, "
@@ -82,11 +86,19 @@ class CreateAccountForm(forms.Form):
)
username = cleaned_data.get('username')
- if username and not iam_admin_client.is_username_available(username):
+ try:
+ if username and not iam_admin_client.is_username_available(
+ username):
+ self.add_error(
+ 'username',
+ forms.ValidationError("That username is not available")
+ )
+ except Exception as e:
+ logger.exception("Failed to check if username is available")
self.add_error(
'username',
- forms.ValidationError("That username is not available")
- )
+ forms.ValidationError("Error occurred while checking if "
+ "username is available: " + str(e)))
return cleaned_data