| 15 | end |
| 16 | |
| 17 | def create |
| 18 | @account = Account.new(account_params) |
| 19 | @account.timezone = Accounts.normalize_timezone(@account.timezone) |
| 20 | @user = @account.users.new(user_params) |
| 21 | @encrypted_config = EncryptedConfig.new(encrypted_config_params) |
| 22 | |
| 23 | unless URI.parse(encrypted_config_params[:value].to_s).class.in?([URI::HTTP, URI::HTTPS]) |
| 24 | @encrypted_config.errors.add(:value, I18n.t('should_be_a_valid_url')) |
| 25 | |
| 26 | return render :index, status: :unprocessable_content |
| 27 | end |
| 28 | |
| 29 | return render :index, status: :unprocessable_content unless @account.valid? |
| 30 | |
| 31 | if @user.save |
| 32 | encrypted_configs = [ |
| 33 | { key: EncryptedConfig::APP_URL_KEY, value: encrypted_config_params[:value] }, |
| 34 | { key: EncryptedConfig::ESIGN_CERTS_KEY, value: GenerateCertificate.call.transform_values(&:to_pem) } |
| 35 | ] |
| 36 | @account.encrypted_configs.create!(encrypted_configs) |
| 37 | @account.account_configs.create!(key: :fulltext_search, value: true) if SearchEntry.table_exists? |
| 38 | |
| 39 | Docuseal.refresh_default_url_options! |
| 40 | |
| 41 | sign_in(@user) |
| 42 | |
| 43 | redirect_to newsletter_path |
| 44 | else |
| 45 | render :index, status: :unprocessable_content |
| 46 | end |
| 47 | end |
| 48 | |
| 49 | private |
| 50 |
no test coverage detected