Skip to content

Commit

Permalink
fix name mixup, small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdaTotoro committed Nov 2, 2021
1 parent 882ab0a commit 7b56ac6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nativeauthenticator/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async def post(self):
if assume_human:
user_info = {
"username": self.get_body_argument("username", strip=False),
"signup_password": self.get_body_argument("pw", 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)),
}
Expand Down
8 changes: 4 additions & 4 deletions nativeauthenticator/nativeauthenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,20 @@ def get_authed_users(self):
def user_exists(self, username):
return self.get_user(username) is not None

def create_user(self, username, pw, **kwargs):
def create_user(self, username, password, **kwargs):
username = self.normalize_username(username)

if self.user_exists(username) or not self.validate_username(username):
return

if not self.is_password_strong(pw):
if not self.is_password_strong(password):
return

if not self.enable_signup:
return

encoded_pw = bcrypt.hashpw(pw.encode(), bcrypt.gensalt())
infos = {"username": username, "password": encoded_pw}
encoded_password = bcrypt.hashpw(password.encode(), bcrypt.gensalt())
infos = {"username": username, "password": encoded_password}
infos.update(kwargs)

if self.open_signup or username in self.get_authed_users():
Expand Down

0 comments on commit 7b56ac6

Please sign in to comment.