Defect #44673 » 0001-Reject-the-current-password-on-lost-password-reset-w.patch
| app/controllers/account_controller.rb | ||
|---|---|---|
|
return
|
||
|
end
|
||
|
if request.post?
|
||
|
if @user.must_change_passwd? && @user.check_password?(params[:new_password])
|
||
|
if @user.must_change_password? && @user.check_password?(params[:new_password])
|
||
|
flash.now[:error] = l(:notice_new_password_must_be_different)
|
||
|
else
|
||
|
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
||
| test/functional/account_controller_test.rb | ||
|---|---|---|
|
assert_select 'input[type=hidden][name=token][value=?]', token.value
|
||
|
end
|
||
|
def test_post_lost_password_with_token_should_not_accept_same_password_if_password_expired
|
||
|
user = User.find(2)
|
||
|
user.password = "originalpassword"
|
||
|
user.save!
|
||
|
user.update_column(:passwd_changed_on, 14.days.ago)
|
||
|
token = Token.create!(:action => 'recovery', :user => user)
|
||
|
with_settings :password_max_age => 7 do
|
||
|
post(
|
||
|
:lost_password,
|
||
|
:params => {
|
||
|
:token => token.value,
|
||
|
:new_password => 'originalpassword',
|
||
|
:new_password_confirmation => 'originalpassword'
|
||
|
}
|
||
|
)
|
||
|
assert user.reload.must_change_password?, "Password expiry was reset"
|
||
|
end
|
||
|
assert_response :success
|
||
|
assert_not_nil Token.find_by_id(token.id), "Token was deleted"
|
||
|
assert_select '.flash', :text => /The new password must be different/
|
||
|
assert_select 'input[type=hidden][name=token][value=?]', token.value
|
||
|
end
|
||
|
def test_post_lost_password_with_token_should_reset_must_change_password
|
||
|
user = User.find(2)
|
||
|
user.password = "originalpassword"
|
||