Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user was added on sign-up even if password didn't match confirmation #271

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions nativeauthenticator/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ async def post(self):
else:
self.authenticator.log.error("Failed reCaptcha")

# Collect various information for precise (error) messages.
password = self.get_body_argument("signup_password", strip=False)
confirmation = self.get_body_argument(
"signup_password_confirmation", strip=False
)
confirmation_matches = password == confirmation
user_is_admin = user_info["username"] in self.authenticator.admin_users
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user_info hasn't been initialised yet


if assume_user_is_human:
user_info = {
"username": self.get_body_argument("username", strip=False),
Expand All @@ -174,19 +182,13 @@ async def post(self):
username_already_taken = self.authenticator.user_exists(
user_info["username"]
)
user = self.authenticator.create_user(**user_info)

if not username_already_taken and confirmation_matches:
user = self.authenticator.create_user(**user_info)
else:
username_already_taken = False
user = None

# Collect various information for precise (error) messages.
password = self.get_body_argument("signup_password", strip=False)
confirmation = self.get_body_argument(
"signup_password_confirmation", strip=False
)
confirmation_matches = password == confirmation
user_is_admin = user_info["username"] in self.authenticator.admin_users

# Call helper function from above for precise alert-level and message.
alert, message = self.get_result_message(
user,
Expand Down
Loading