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 <rrlmachado@inf.ufpr.br>
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
end
@resource = Account.find_by(uid: params[:cpf])
if @resource.citizen.email.nil? or @resource.citizen.email.empty?
@resource = Account.find_by(uid: params[:cpf])
if @resource.nil? or @resource.citizen.email.nil? or @resource.citizen.email.empty?
render json: {
errors: ["User #{params[:cpf]} does not have an email registered."]
}, status: 422
return
end
@resource.email = @resource.citizen.email
@resource.email = @resource.citizen.email
@resource.save
@email = @resource.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