adopt-a-hydrant/app/controllers/passwords_controller.rb

28 lines
757 B
Ruby
Raw Normal View History

2011-03-07 02:40:29 +00:00
class PasswordsController < Devise::PasswordsController
def create
2012-06-18 17:49:28 +00:00
self.resource = resource_class.send_reset_password_instructions(resource_params)
2011-03-07 02:40:29 +00:00
if resource.errors.empty?
2012-06-18 17:49:28 +00:00
render(json: {success: true})
2011-03-07 02:40:29 +00:00
else
2012-06-18 17:49:28 +00:00
render(json: {errors: resource.errors}, status: 500)
2011-03-07 02:40:29 +00:00
end
end
def edit
self.resource = resource_class.new
resource.reset_password_token = params[:reset_password_token]
2012-06-18 17:49:28 +00:00
render("edit", layout: "info_window")
2011-03-07 02:40:29 +00:00
end
def update
2012-06-18 17:49:28 +00:00
self.resource = resource_class.reset_password_by_token(resource_params)
redirect_to(controller: "main", action: "index")
2011-03-07 02:40:29 +00:00
end
private
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation, :reset_password_token)
end
2011-03-07 02:40:29 +00:00
end