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

Error on signup with taken username #102

Merged
merged 5 commits into from
Mar 29, 2020

Conversation

lambdaTotoro
Copy link
Collaborator

Fixes #91, including an additional test for signing up with the same username multiple times and a fitting error message on rejected signup.

In the course of this, I refactored the get_or_create_user() method into three methods: user_exists(), get_user() and create_user() which gets rid of the signup error (which was related to getting a user when, really, you wanted to create a user).

I also replaced calls to UserInfo without username normalization in the authenticator with calls to the aforementioned get_user(), which does include username normalization.

user = UserInfo.find(self.db, username)

def get_user(self, username):
user = UserInfo.find(self.db, self.normalize_username(username))
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I am not mistaken, if the user doesn't exist it already returns None, so we can remove the following if and just return the result of this search

Comment on lines 172 to 173
if user:
return user
Copy link
Collaborator

Choose a reason for hiding this comment

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

then this won't be necessary


def create_user(self, username, pw, **kwargs):

Copy link
Collaborator

Choose a reason for hiding this comment

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

can you remove this line to follow patterns please?

@leportella
Copy link
Collaborator

I asked for a couple of minor things but it looks great! Thanks for your pull request

@lambdaTotoro
Copy link
Collaborator Author

I have incorporated the changes you pointed out. You were absolutely correct, the if user:-block was entirely unnecessary. I also added a test for this method.

@leportella leportella merged commit b312263 into jupyterhub:master Mar 29, 2020
@leportella
Copy link
Collaborator

thanks!

@lambdaTotoro lambdaTotoro mentioned this pull request Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Signup with taken username doesn't error
2 participants