From 75d2c0ea3c8fbce92594a0282ea97dc947501f6a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 2 Jun 2017 20:49:30 +1200 Subject: [PATCH] destroy member if password correct --- app/controllers/registrations_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 7b23f988c..552f12870 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -35,6 +35,14 @@ class RegistrationsController < Devise::RegistrationsController render "edit" end end + + def destroy + if @member.destroy_with_password(params.require(:member)[:current_password]) + redirect_to root_path + else + render "edit" + end + end end # check if we need the current password to update fields