forked from pallets-eco/flask-security-3.0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pallets-eco#389 from nickretallack/develop
Reset Password Fixes
- Loading branch information
Showing
4 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,5 @@ env/ | |
Session.vim | ||
.netrwhist | ||
*~ | ||
|
||
.eggs/README.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,47 @@ def test_expired_reset_token(client, get_message): | |
assert msg in response.data | ||
|
||
|
||
def test_used_reset_token(client, get_message): | ||
with capture_reset_password_requests() as requests: | ||
client.post('/reset', data=dict(email='[email protected]'), follow_redirects=True) | ||
|
||
token = requests[0]['token'] | ||
|
||
# use the token | ||
response = client.post('/reset/' + token, data={ | ||
'password': 'newpassword', | ||
'password_confirm': 'newpassword' | ||
}, follow_redirects=True) | ||
|
||
assert get_message('PASSWORD_RESET') in response.data | ||
|
||
logout(client) | ||
|
||
# attempt to use it a second time | ||
response2 = client.post('/reset/' + token, data={ | ||
'password': 'otherpassword', | ||
'password_confirm': 'otherpassword' | ||
}, follow_redirects=True) | ||
|
||
msg = get_message('INVALID_RESET_PASSWORD_TOKEN') | ||
assert msg in response2.data | ||
|
||
|
||
def test_reset_passwordless_user(client, get_message): | ||
with capture_reset_password_requests() as requests: | ||
client.post('/reset', data=dict(email='[email protected]'), follow_redirects=True) | ||
|
||
token = requests[0]['token'] | ||
|
||
# use the token | ||
response = client.post('/reset/' + token, data={ | ||
'password': 'newpassword', | ||
'password_confirm': 'newpassword' | ||
}, follow_redirects=True) | ||
|
||
assert get_message('PASSWORD_RESET') in response.data | ||
|
||
|
||
@pytest.mark.settings(reset_url='/custom_reset') | ||
def test_custom_reset_url(client): | ||
response = client.get('/custom_reset') | ||
|