add the app url input on the first setup page

This commit is contained in:
Alex Turchyn
2023-06-20 23:42:56 +03:00
parent 4977ee429c
commit 0ac30a5fc0
14 changed files with 93 additions and 11 deletions
+23
View File
@@ -1,6 +1,10 @@
# frozen_string_literal: true
class ProfileController < ApplicationController
before_action :load_encrypted_config, only: %i[index update_app_url]
def index; end
def update_contact
if current_user.update(contact_params)
redirect_to settings_profile_index_path, notice: 'Contact information successfully updated'
@@ -18,8 +22,23 @@ class ProfileController < ApplicationController
end
end
def update_app_url
if @encrypted_config.update(app_url_params)
Docuseal.refresh_default_url_options!
redirect_to settings_profile_index_path, notice: 'App URL successfully changed'
else
render :index, status: :unprocessable_entity
end
end
private
def load_encrypted_config
@encrypted_config =
EncryptedConfig.find_or_initialize_by(account: current_account, key: EncryptedConfig::APP_URL_KEY)
end
def contact_params
params.require(:user).permit(:first_name, :last_name, :email, account_attributes: %i[name])
end
@@ -27,4 +46,8 @@ class ProfileController < ApplicationController
def password_params
params.require(:user).permit(:password, :password_confirmation)
end
def app_url_params
params.require(:encrypted_config).permit(:value)
end
end