Avoid sql indexing by instantiating User earlier.

This commit is contained in:
voussoir 2018-02-16 18:40:57 -08:00
parent bc4e228a25
commit 4e8a67aa54
2 changed files with 4 additions and 3 deletions

View file

@ -1293,6 +1293,7 @@ class User(ObjectBase):
self.id = db_row['id']
self.username = db_row['username']
self.created = db_row['created']
self.password_hash = db_row['password']
def __repr__(self):
rep = 'User:{id}:{username}'.format(id=self.id, username=self.username)

View file

@ -878,13 +878,13 @@ class PDBUserMixin:
if not isinstance(password, bytes):
password = password.encode('utf-8')
stored_password = fetch[constants.SQL_USER['password']]
user = objects.User(self, fetch)
success = bcrypt.checkpw(password, stored_password)
success = bcrypt.checkpw(password, user.password_hash)
if not success:
raise exceptions.WrongLogin()
return objects.User(self, fetch)
return user
@decorators.required_feature('user.new')
@decorators.transaction