logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

deletes_controller.rb (798B)


  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. 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