Commit 3399c98f authored by Rafael Ravedutti's avatar Rafael Ravedutti

Avoid internal server error when resetting password for unregistered CPF

Signed-off-by: Rafael Ravedutti's avatarRafael Ravedutti <>
parent 239bb842
Pipeline #16866 passed with stages
in 3 minutes and 39 seconds
module Api::V1
module Api::V1
class Accounts::PasswordsController < DeviseTokenAuth::PasswordsController
# this action is responsible for generating password reset tokens and
......@@ -11,20 +11,20 @@ module Api::V1
# fall back to default value if provided
@redirect_url ||= DeviseTokenAuth.default_password_reset_url
unless @redirect_url
return render_create_error_missing_redirect_url
@resource = Account.find_by(uid: params[:cpf])
if or
@resource = Account.find_by(uid: params[:cpf])
if @resource.nil? or or
render json: {
errors: ["User #{params[:cpf]} does not have an email registered."]
}, status: 422
end = =
@email =
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment