You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
756 B

  1. # frozen_string_literal: true
  2. class Settings::DeletesController < Settings::BaseController
  3. prepend_before_action :check_enabled_deletion
  4. def show
  5. @confirmation = Form::DeleteConfirmation.new
  6. end
  7. def destroy
  8. if current_user.valid_password?(delete_params[:password])
  9. Admin::SuspensionWorker.perform_async(current_user.account_id, true)
  10. sign_out
  11. redirect_to new_user_session_path, notice: I18n.t('deletes.success_msg')
  12. else
  13. redirect_to settings_delete_path, alert: I18n.t('deletes.bad_password_msg')
  14. end
  15. end
  16. private
  17. def check_enabled_deletion
  18. redirect_to root_path unless Setting.open_deletion
  19. end
  20. def delete_params
  21. params.require(:form_delete_confirmation).permit(:password)
  22. end
  23. end