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
+12 -2
View File
@@ -10,6 +10,7 @@ class SetupController < ApplicationController
def index
@account = Account.new(account_params)
@user = @account.users.new(user_params)
@encrypted_config = EncryptedConfig.new(account: @account, key: EncryptedConfig::APP_URL_KEY)
end
def create
@@ -17,8 +18,11 @@ class SetupController < ApplicationController
@user = @account.users.new(user_params)
if @user.save
@account.encrypted_configs.create!(key: EncryptedConfig::ESIGN_CERTS_KEY,
value: GenerateCertificate.call)
encrypted_configs = [
{ key: EncryptedConfig::APP_URL_KEY, value: encrypted_config_params[:value] },
{ key: EncryptedConfig::ESIGN_CERTS_KEY, value: GenerateCertificate.call }
]
@account.encrypted_configs.create!(encrypted_configs)
sign_in(@user)
@@ -42,6 +46,12 @@ class SetupController < ApplicationController
params.require(:account).permit(:name)
end
def encrypted_config_params
return {} unless params[:encrypted_config]
params.require(:encrypted_config).permit(:value)
end
def redirect_to_root_if_signed
redirect_to root_path, notice: 'You are already signed in'
end