@users @admin Feature: User Authentication Scenario: Forgot password Given I have no users And the following activated user exists | login | password | | sam | secret | And all emails have been delivered When I am on the home page And I fill in "Username or email:" with "sam" And I fill in "Password:" with "test" And I press "Log In" Then I should see "The password or username you entered doesn't match our records" And I should see "Forgot your password or username?" When I follow "Reset password" Then I should see "Please tell us the username or email address you used when you signed up for your Archive account" When I fill in "Email address or username" with "sam" And I press "Reset Password" Then I should see "Check your email for instructions on how to reset your password." And 1 email should be delivered And the email should contain "sam" And the email should contain "Someone has requested a password reset for your account" And the email should not contain "translation missing" # existing password should still work When I am on the homepage And I fill in "Username or email:" with "sam" And I fill in "Password:" with "secret" And I press "Log In" Then I should see "Hi, sam" # link from the email should not work when logged in When I follow "Change my password." in the email Then I should see "You are already signed in." And I should not see "Change My Password" # link from the email should work When I log out And I follow "Change my password." in the email Then I should see "Change My Password" # entering mismatched passwords should produce an error message When I fill in "New password" with "secret" And I fill in "Confirm new password" with "newpass" And I press "Change Password" Then I should see "We couldn't save this user because:" And I should see "Password confirmation doesn't match new password." # and I should be able to change the password When I fill in "New password" with "new When I am on the home page And I follow "Forgot password?" And I fill in "Email address or username" with "target" And I press "Reset Password" Then I should be on the home page And I should see "Password resets are disabled for that user." And 0 emails should be delivered When I follow "Forgot password?" And I fill in "Email address or username" with "user@example.com" And I press "Reset Password" Then I should be on the home page And I should see "Password resets are disabled for that user." And 0 emails should be delivered Examples: | role | | is a protected user | | has the no resets role | Scenario: Admin cannot log in or reset password as ordinary user. Given the following admin exists | login | password | | admin | adminpassword | When I go to the login page And I fill in "Username or email" with "admin" And I fill in "Password" with "adminpassword" And I press "Log In" Then I should not see "Successfully logged in" And I should see "The password or username you entered doesn't match our records." When I am logged in as an admin And I go to the new user password page Then I should be on the homepage And I should see "Please log out of your admin account first!" When I go to the edit user password page Then I should be on the homepage And I should see "Please log out of your admin account first!"