闭社主体 forked from https://github.com/tootsuite/mastodon
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.

32 lines
801 B

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