diff options
author | ThibG <thib@sitedethib.com> | 2020-04-20 18:25:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-20 18:25:18 +0200 |
commit | 60f8a63a76f7c866b5338c33a8b897ba022368ca (patch) | |
tree | b816c0e92ade09712e9bcce29716e762f38769c1 /app/controllers/settings | |
parent | d5530827c984238f93100ee737ed209d61e316c0 (diff) | |
parent | 221ea4787fe0caf0f8a3238ab95e97aaac8fe360 (diff) |
Merge pull request #1320 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/controllers/settings')
-rw-r--r-- | app/controllers/settings/pictures_controller.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/controllers/settings/pictures_controller.rb b/app/controllers/settings/pictures_controller.rb new file mode 100644 index 000000000..73926707b --- /dev/null +++ b/app/controllers/settings/pictures_controller.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module Settings + class PicturesController < BaseController + before_action :authenticate_user! + before_action :set_account + before_action :set_picture + + def destroy + if valid_picture + account_params = { + @picture => nil, + (@picture + '_remote_url') => nil, + } + + msg = UpdateAccountService.new.call(@account, account_params) ? I18n.t('generic.changes_saved_msg') : nil + redirect_to settings_profile_path, notice: msg, status: 303 + else + bad_request + end + end + + private + + def set_account + @account = current_account + end + + def set_picture + @picture = params[:id] + end + + def valid_picture + @picture == 'avatar' || @picture == 'header' + end + end +end |