From ad9e4938bc2ae92de3983fe958796d23392663bb Mon Sep 17 00:00:00 2001 From: Ronan Date: Thu, 31 Aug 2023 16:25:12 +1000 Subject: [PATCH 1/3] Add additional log information Print out the message returned by create_local_user() when it fails to create a new local user. --- powerdnsadmin/routes/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerdnsadmin/routes/index.py b/powerdnsadmin/routes/index.py index d56ce61..23d88bb 100644 --- a/powerdnsadmin/routes/index.py +++ b/powerdnsadmin/routes/index.py @@ -258,7 +258,7 @@ def login(): result = user.create_local_user() if not result['status']: - current_app.logger.warning('Unable to create ' + azure_username) + current_app.logger.warning('Unable to create ' + azure_username + ' Reasoning: ' + result['msg']) session.pop('azure_token', None) # note: a redirect to login results in an endless loop, so render the login page instead return render_template('login.html', From 7fcd2b8aa6ebcf2074ad4fadc92a33162d704e42 Mon Sep 17 00:00:00 2001 From: Ronan Date: Thu, 31 Aug 2023 16:26:48 +1000 Subject: [PATCH 2/3] Fix case sensitivity for duplicate username creation --- powerdnsadmin/models/user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerdnsadmin/models/user.py b/powerdnsadmin/models/user.py index e989aa0..f1673a5 100644 --- a/powerdnsadmin/models/user.py +++ b/powerdnsadmin/models/user.py @@ -408,7 +408,7 @@ class User(db.Model): Create local user witch stores username / password in the DB """ # check if username existed - user = User.query.filter(User.username == self.username).first() + user = User.query.filter(User.username.lower() == self.username.lower()).first() if user: return {'status': False, 'msg': 'Username is already in use'} From c52bdd0daf66047e41f56db4967819162861dd46 Mon Sep 17 00:00:00 2001 From: Ronan Date: Thu, 31 Aug 2023 16:28:06 +1000 Subject: [PATCH 3/3] Fix case sensitivity for duplicate email creation --- powerdnsadmin/models/user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerdnsadmin/models/user.py b/powerdnsadmin/models/user.py index f1673a5..5a24c91 100644 --- a/powerdnsadmin/models/user.py +++ b/powerdnsadmin/models/user.py @@ -413,7 +413,7 @@ class User(db.Model): return {'status': False, 'msg': 'Username is already in use'} # check if email existed - user = User.query.filter(User.email == self.email).first() + user = User.query.filter(User.email.lower() == self.email.lower()).first() if user: return {'status': False, 'msg': 'Email address is already in use'}