From 1c9d0f74a4dd46bc50a2fcf3702098c072ea507c Mon Sep 17 00:00:00 2001 From: Jonas Betzendahl Date: Wed, 22 Apr 2020 15:38:24 +0200 Subject: [PATCH 1/5] fix signup handling --- nativeauthenticator/handlers.py | 54 +++++++++++++++++---------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/nativeauthenticator/handlers.py b/nativeauthenticator/handlers.py index 4fb10b4..e9fb2b1 100644 --- a/nativeauthenticator/handlers.py +++ b/nativeauthenticator/handlers.py @@ -43,33 +43,35 @@ async def get(self): ) self.finish(html) - def get_result_message(self, user, username): + def get_result_message(self, user, taken): alert = 'alert-info' - message = 'Your information have been sent to the admin' + message = 'Your information has been sent to the admin' - if self.authenticator.open_signup: - alert = 'alert-success' - message = ('The signup was successful. You can now go to ' - 'home page and log in the system') - if not user: + # Always error if username is taken. + if taken: alert = 'alert-danger' - pw_len = self.authenticator.minimum_password_length - taken = self.authenticator.user_exists(username) - - if pw_len: - message = ("Something went wrong. Be sure your password has " - "at least {} characters, doesn't have spaces or " - "commas and is not too common.").format(pw_len) - - elif taken: - message = ("Something went wrong. It appears that this " - "username is already in use. Please try again " - "with a different username.") - - else: - message = ("Something went wrong. Be sure your password " - " doesn't have spaces or commas and is not too " - "common.") + message = ("Something went wrong. It appears that this " + "username is already in use. Please try again " + "with a different username.") + else: + # Error if user creation was not successful. + if not user: + alert = 'alert-danger' + pw_len = self.authenticator.minimum_password_length + if pw_len: + message = ("Something went wrong. Be sure your password has " + "at least {} characters, doesn't have spaces or " + "commas and is not too common.").format(pw_len) + else: + message = ("Something went wrong. Be sure your password " + " doesn't have spaces or commas and is not too " + "common.") + + # If user creation went through and open-signup is enabled, success. + elif self.authenticator.open_signup: + alert = 'alert-success' + message = ('The signup was successful. You can now go to ' + 'home page and log in the system') return alert, message @@ -83,10 +85,10 @@ async def post(self): 'email': self.get_body_argument('email', '', strip=False), 'has_2fa': bool(self.get_body_argument('2fa', '', strip=False)), } + taken = self.authenticator.user_exists(user_info['username']) user = self.authenticator.create_user(**user_info) - name = self.authenticator.user_exists(user_info['username']) - alert, message = self.get_result_message(user, name) + alert, message = self.get_result_message(user, taken) otp_secret, user_2fa = '', '' if user: From 1e9971b045fc1f04a904a02d670d75e692a5ea29 Mon Sep 17 00:00:00 2001 From: Jonas Betzendahl Date: Wed, 22 Apr 2020 15:45:58 +0200 Subject: [PATCH 2/5] tabs/spaces --- nativeauthenticator/handlers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nativeauthenticator/handlers.py b/nativeauthenticator/handlers.py index e9fb2b1..e3c8235 100644 --- a/nativeauthenticator/handlers.py +++ b/nativeauthenticator/handlers.py @@ -54,7 +54,7 @@ def get_result_message(self, user, taken): "username is already in use. Please try again " "with a different username.") else: - # Error if user creation was not successful. + # Error if user creation was not successful. if not user: alert = 'alert-danger' pw_len = self.authenticator.minimum_password_length @@ -66,8 +66,8 @@ def get_result_message(self, user, taken): message = ("Something went wrong. Be sure your password " " doesn't have spaces or commas and is not too " "common.") - - # If user creation went through and open-signup is enabled, success. + + # If user creation went through and open-signup is enabled, success. elif self.authenticator.open_signup: alert = 'alert-success' message = ('The signup was successful. You can now go to ' From 0fc21ad1734e3edf27c6a79659bc3bff38008cbc Mon Sep 17 00:00:00 2001 From: Jonas Betzendahl Date: Wed, 22 Apr 2020 18:24:25 +0200 Subject: [PATCH 3/5] typo --- nativeauthenticator/templates/native-login.html | 2 +- nativeauthenticator/templates/signup.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nativeauthenticator/templates/native-login.html b/nativeauthenticator/templates/native-login.html index 3303bef..2ac9672 100644 --- a/nativeauthenticator/templates/native-login.html +++ b/nativeauthenticator/templates/native-login.html @@ -54,7 +54,7 @@ {% if enable_signup %}
-

Don't have an user? Signup!

+

Don't have an account? Signup!

{% endif %} diff --git a/nativeauthenticator/templates/signup.html b/nativeauthenticator/templates/signup.html index 04b9f34..4daee9c 100644 --- a/nativeauthenticator/templates/signup.html +++ b/nativeauthenticator/templates/signup.html @@ -44,7 +44,7 @@ {% endif %}
- Already have an user? Login! + Already have an account? Login!
{% if alert %} {% endblock login %} -{% endblock %} \ No newline at end of file +{% endblock %} From 99bce9544677f0512a5967412795011eee630c09 Mon Sep 17 00:00:00 2001 From: Jonas Betzendahl Date: Fri, 24 Apr 2020 16:11:39 +0200 Subject: [PATCH 4/5] fix line length and overindentation --- nativeauthenticator/handlers.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/nativeauthenticator/handlers.py b/nativeauthenticator/handlers.py index e3c8235..85df601 100644 --- a/nativeauthenticator/handlers.py +++ b/nativeauthenticator/handlers.py @@ -44,34 +44,35 @@ async def get(self): self.finish(html) def get_result_message(self, user, taken): - alert = 'alert-info' + alert = 'alert-info' message = 'Your information has been sent to the admin' # Always error if username is taken. if taken: alert = 'alert-danger' message = ("Something went wrong. It appears that this " - "username is already in use. Please try again " - "with a different username.") + "username is already in use. Please try again " + "with a different username.") else: # Error if user creation was not successful. if not user: alert = 'alert-danger' pw_len = self.authenticator.minimum_password_length if pw_len: - message = ("Something went wrong. Be sure your password has " - "at least {} characters, doesn't have spaces or " - "commas and is not too common.").format(pw_len) + message = ("Something went wrong. Be sure your " + "password has at least {} characters, doesn't " + "have spaces or commas and is not too " + "common.").format(pw_len) else: message = ("Something went wrong. Be sure your password " - " doesn't have spaces or commas and is not too " + "doesn't have spaces or commas and is not too " "common.") - # If user creation went through and open-signup is enabled, success. + # If user creation went through & open-signup is enabled, success. elif self.authenticator.open_signup: alert = 'alert-success' message = ('The signup was successful. You can now go to ' - 'home page and log in the system') + 'home page and log in the system') return alert, message From bd61472541590f0cbd5af99f1d4a389220fb1fe3 Mon Sep 17 00:00:00 2001 From: Jonas Betzendahl Date: Fri, 24 Apr 2020 16:18:41 +0200 Subject: [PATCH 5/5] fix multiple spaces before operator --- nativeauthenticator/handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nativeauthenticator/handlers.py b/nativeauthenticator/handlers.py index 85df601..ecbf24a 100644 --- a/nativeauthenticator/handlers.py +++ b/nativeauthenticator/handlers.py @@ -44,7 +44,7 @@ async def get(self): self.finish(html) def get_result_message(self, user, taken): - alert = 'alert-info' + alert = 'alert-info' message = 'Your information has been sent to the admin' # Always error if username is taken.