-
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
Error on signup with taken username #102
Conversation
user = UserInfo.find(self.db, username) | ||
|
||
def get_user(self, username): | ||
user = UserInfo.find(self.db, self.normalize_username(username)) |
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.
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
if user: | ||
return user |
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.
then this won't be necessary
|
||
def create_user(self, username, pw, **kwargs): | ||
|
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.
can you remove this line to follow patterns please?
I asked for a couple of minor things but it looks great! Thanks for your pull request |
I have incorporated the changes you pointed out. You were absolutely correct, the |
thanks! |
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()
andcreate_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.