silum
2017-11-03 ff8df6916de86e037b0f8f37a8b29ad0437e5348
views.py: prevent exception on unknown user login

Attempting authentication without specifying a login, or when the login is not known, causes an unhandled exception to be raised in `security.py` because `None` is passed to `check_password()` as the hashed password to check against.

(cherry picked from commit b83d693)
1 files modified
3 ■■■■ changed files
docs/quick_tutorial/authentication/tutorial/views.py 3 ●●●● patch | view | raw | blame | history
docs/quick_tutorial/authentication/tutorial/views.py
@@ -43,7 +43,8 @@
        if 'form.submitted' in request.params:
            login = request.params['login']
            password = request.params['password']
            if check_password(password, USERS.get(login)):
            hashed_pw = USERS.get(login)
            if hashed_pw and check_password(password, hashed_pw):
                headers = remember(request, login)
                return HTTPFound(location=came_from,
                                 headers=headers)