-
Notifications
You must be signed in to change notification settings - Fork 69
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 #275
Merged
consideRatio
merged 4 commits into
jupyterhub:main
from
consideRatio:pr/fix-create-user
Sep 17, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
32d3843
Fix user was added on sign-up even if password didn't match confirmation
paolocarinci 2760f19
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7e5e197
Better fix for mismatching passwords on signup
c4d38f5
Ensure variables are initialized before use
consideRatio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,28 +164,28 @@ async def post(self): | |
else: | ||
self.authenticator.log.error("Failed reCaptcha") | ||
|
||
if assume_user_is_human: | ||
user_info = { | ||
"username": self.get_body_argument("username", strip=False), | ||
"password": self.get_body_argument("signup_password", strip=False), | ||
"email": self.get_body_argument("email", "", strip=False), | ||
"has_2fa": bool(self.get_body_argument("2fa", "", strip=False)), | ||
} | ||
username_already_taken = self.authenticator.user_exists( | ||
user_info["username"] | ||
) | ||
user = self.authenticator.create_user(**user_info) | ||
else: | ||
username_already_taken = False | ||
user = None | ||
|
||
# Collect various information for precise (error) messages. | ||
# initialize user_info | ||
user_info = { | ||
"username": self.get_body_argument("username", strip=False), | ||
"password": self.get_body_argument("signup_password", strip=False), | ||
"email": self.get_body_argument("email", "", strip=False), | ||
"has_2fa": bool(self.get_body_argument("2fa", "", strip=False)), | ||
} | ||
username = user_info["username"] | ||
|
||
# summarize info | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
user_is_admin = username in self.authenticator.admin_users | ||
username_already_taken = self.authenticator.user_exists(username) | ||
|
||
# if everything seems ok, create a user | ||
user = None | ||
if assume_user_is_human and not username_already_taken and confirmation_matches: | ||
user = self.authenticator.create_user(**user_info) | ||
|
||
# Call helper function from above for precise alert-level and message. | ||
alert, message = self.get_result_message( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is now always done which I think is perfectly fine in this case.