Change user search from .one to .fine_one.
When searching for a user by username, there can either be no result or one result. There is a unique constraint on the db. .one in mongokit raises an error for more than one result. But that can't happen anyway. So no problem. .one in sqlalchemy raises an error for more than one, but that's not a problem anyway. It also raises an error for no result. But no result is handled by the code anyway, so no need to raise an exception. .find_one doesn't raise an exception for more than one result (no problem anyway) and just returns None for no result. The later is handled by the code.
This commit is contained in:
parent
dd0799ad0a
commit
84812db59d
@ -120,7 +120,7 @@ def login(request):
|
||||
login_failed = False
|
||||
|
||||
if request.method == 'POST' and login_form.validate():
|
||||
user = request.db.User.one(
|
||||
user = request.db.User.find_one(
|
||||
{'username': request.POST['username'].lower()})
|
||||
|
||||
if user and user.check_login(request.POST['password']):
|
||||
|
Loading…
x
Reference in New Issue
Block a user