-
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
Signup error #109
Merged
Merged
Signup error #109
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
|
@@ -43,33 +43,36 @@ 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 & 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 +86,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']) | ||
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. Variable name was confusing, this is a boolean that indicates if the name is taken, not the name as a string. |
||
|
||
alert, message = self.get_result_message(user, name) | ||
alert, message = self.get_result_message(user, taken) | ||
|
||
otp_secret, user_2fa = '', '' | ||
if user: | ||
|
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
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
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 is the line that caused the errors. "username" here is a boolean indicating wether the name exists in the system, but it is used like a string containing a username. Apart from this being nonsensical, during jupyterhub username normalisation,
.lower()
is called on this variable, which throws an error because that's not defined on booleans, leading to a 500 error.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.
that's a great catch