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.

37 lines
890 B

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