diff --git a/app/controllers/account_logo_controller.rb b/app/controllers/account_logo_controller.rb new file mode 100644 index 00000000..c58ad971 --- /dev/null +++ b/app/controllers/account_logo_controller.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class AccountLogoController < ApplicationController + before_action :authorize_account_config + + def create + file = params[:file] + + if file.blank? + return redirect_to settings_personalization_path, alert: I18n.t('unable_to_save') + end + + current_account.logo.attach(file) + + redirect_to settings_personalization_path, notice: I18n.t('settings_have_been_saved') + end + + def destroy + current_account.logo.purge + + redirect_to settings_personalization_path, notice: I18n.t('settings_have_been_saved') + end + + private + + def authorize_account_config + authorize!(:create, AccountConfig) + end +end diff --git a/app/models/account.rb b/app/models/account.rb index d3d53d0c..6ca102ef 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -20,6 +20,8 @@ class Account < ApplicationRecord attribute :uuid, :string, default: -> { SecureRandom.uuid } + has_one_attached :logo + has_many :users, dependent: :destroy has_many :encrypted_configs, dependent: :destroy has_many :account_configs, dependent: :destroy diff --git a/app/views/personalization_settings/_logo_form.html.erb b/app/views/personalization_settings/_logo_form.html.erb index fc6f3ac7..9a84b78b 100644 --- a/app/views/personalization_settings/_logo_form.html.erb +++ b/app/views/personalization_settings/_logo_form.html.erb @@ -1 +1,34 @@ -<%= render 'logo_placeholder' %> +<% if current_account.logo.attached? %> +
- <%= t('unlock_with_docuseal_pro') %> -
-
- <%= t('display_your_company_name_and_logo_when_signing_documents') %>
-
- " data-turbo="false">
- <%= t('learn_more') %>
-
-