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
713 B

  1. # frozen_string_literal: true
  2. module Settings
  3. class PicturesController < BaseController
  4. before_action :authenticate_user!
  5. before_action :set_account
  6. before_action :set_picture
  7. def destroy
  8. if valid_picture?
  9. msg = I18n.t('generic.changes_saved_msg') if UpdateAccountService.new.call(@account, { @picture => nil, "#{@picture}_remote_url" => '' })
  10. redirect_to settings_profile_path, notice: msg, status: 303
  11. else
  12. bad_request
  13. end
  14. end
  15. private
  16. def set_account
  17. @account = current_account
  18. end
  19. def set_picture
  20. @picture = params[:id]
  21. end
  22. def valid_picture?
  23. %w(avatar header).include?(@picture)
  24. end
  25. end
  26. end