diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3e6221d06..f4b94d104 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -72,7 +72,9 @@ class ApplicationController < ActionController::Base # email settings :show_email, :newsletter, :send_notification_email, :send_planting_reminder, # update password - :current_password) + :current_password, + # is the account deleted + :deleted) end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index dd89f6311..b33a039b8 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -54,6 +54,11 @@ class MembersController < ApplicationController end end + def destroy + @member.update!(deleted: true) + redirect_to root_path + end + def view_follows @member = Member.confirmed.find(params[:login_name]) @follows = @member.followed.paginate(page: params[:page]) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 98651eb00..7b23f988c 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -40,5 +40,6 @@ end # check if we need the current password to update fields def needs_password?(member, params) params[:member][:password].present? || - params[:member][:password_confirmation].present? + params[:member][:password_confirmation].present? || + params[:member][:deleted].present? end diff --git a/app/views/devise/registrations/_delete.html.haml b/app/views/devise/registrations/_delete.html.haml new file mode 100644 index 000000000..89a7659e7 --- /dev/null +++ b/app/views/devise/registrations/_delete.html.haml @@ -0,0 +1,13 @@ += form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'form-horizontal' }) do |f| + %br/ + = devise_error_messages! + + .form-group + = f.label :current_password, "Password required to delete", class: 'control-label col-md-2' + .col-md-4 + = f.password_field :current_password, :class => 'form-control', id: 'current_pw_for_delete' + + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit "Delete", class: 'btn btn-primary' + =f.hidden_field(:deleted, value: true)