Skip to content

Commit 7437b2a

Browse files
authored
Merge pull request #6408 from JenMcD-star/5260-Suppress-Erroneous-Email-Reset-Warning
5260 suppress erroneous email reset warning
2 parents 394b19c + 17803d8 commit 7437b2a

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

app/controllers/users/passwords_controller.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ def create
1818
notice: "If the account exists you will receive an email or SMS with instructions on how to reset your password in a few minutes."
1919
end
2020

21+
def update
22+
self.resource = resource_class.reset_password_by_token(resource_params)
23+
24+
yield resource if block_given?
25+
26+
if resource.errors.empty?
27+
flash[:notice] = "Your password has been changed successfully."
28+
redirect_to new_session_path(resource_name)
29+
else
30+
respond_with resource
31+
end
32+
end
33+
2134
private
2235

2336
def render_error

spec/requests/users/passwords_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,30 @@
123123
end
124124
end
125125
end
126+
127+
describe "PUT /update" do
128+
let(:token) do
129+
raw_token, enc_token = Devise.token_generator.generate(User, :reset_password_token)
130+
user.update!(reset_password_token: enc_token, reset_password_sent_at: Time.current)
131+
raw_token
132+
end
133+
134+
let(:params) do
135+
{
136+
user: {
137+
reset_password_token: token,
138+
password: "newpassword123!",
139+
password_confirmation: "newpassword123!"
140+
}
141+
}
142+
end
143+
144+
subject(:submit_reset) { put user_password_path, params: params }
145+
146+
it "successfully resets the password" do
147+
submit_reset
148+
expect(response).to redirect_to(new_user_session_path)
149+
expect(flash[:notice]).to eq("Your password has been changed successfully.")
150+
end
151+
end
126152
end

0 commit comments

Comments
 (0)