Avoid sql indexing by instantiating User earlier.
This commit is contained in:
parent
bc4e228a25
commit
4e8a67aa54
2 changed files with 4 additions and 3 deletions
|
@ -1293,6 +1293,7 @@ class User(ObjectBase):
|
||||||
self.id = db_row['id']
|
self.id = db_row['id']
|
||||||
self.username = db_row['username']
|
self.username = db_row['username']
|
||||||
self.created = db_row['created']
|
self.created = db_row['created']
|
||||||
|
self.password_hash = db_row['password']
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
rep = 'User:{id}:{username}'.format(id=self.id, username=self.username)
|
rep = 'User:{id}:{username}'.format(id=self.id, username=self.username)
|
||||||
|
|
|
@ -878,13 +878,13 @@ class PDBUserMixin:
|
||||||
if not isinstance(password, bytes):
|
if not isinstance(password, bytes):
|
||||||
password = password.encode('utf-8')
|
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:
|
if not success:
|
||||||
raise exceptions.WrongLogin()
|
raise exceptions.WrongLogin()
|
||||||
|
|
||||||
return objects.User(self, fetch)
|
return user
|
||||||
|
|
||||||
@decorators.required_feature('user.new')
|
@decorators.required_feature('user.new')
|
||||||
@decorators.transaction
|
@decorators.transaction
|
||||||
|
|
Loading…
Reference in a new issue