diff --git a/Gemfile b/Gemfile index d6d711d2..da61a3a7 100644 --- a/Gemfile +++ b/Gemfile @@ -21,10 +21,6 @@ gem 'jwt' gem 'lograge' gem 'mysql2', require: false gem 'oj' -gem 'omniauth-github' -gem 'omniauth-google-oauth2' -gem 'omniauth-microsoft-office365' -gem 'omniauth-rails_csrf_protection' gem 'pagy' gem 'pdf-reader' gem 'pg', require: false diff --git a/Gemfile.lock b/Gemfile.lock index c4107333..4654547c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -245,7 +245,6 @@ GEM signet (>= 0.16, < 2.a) hashdiff (1.0.1) hashery (2.1.2) - hashie (5.0.0) hexapdf (0.34.1) cmdparse (~> 3.0, >= 3.0.3) geom2d (~> 0.4, >= 0.4.1) @@ -296,7 +295,6 @@ GEM minitest (5.20.0) msgpack (1.7.2) multi_json (1.15.0) - multi_xml (0.6.0) multipart-post (2.3.0) mysql2 (0.5.5) net-http-persistent (4.0.2) @@ -316,35 +314,7 @@ GEM racc (~> 1.4) nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) - oauth2 (2.0.9) - faraday (>= 0.17.3, < 3.0) - jwt (>= 1.0, < 3.0) - multi_xml (~> 0.5) - rack (>= 1.2, < 4) - snaky_hash (~> 2.0) - version_gem (~> 1.1) oj (3.16.0) - omniauth (2.1.1) - hashie (>= 3.4.6) - rack (>= 2.2.3) - rack-protection - omniauth-github (2.0.1) - omniauth (~> 2.0) - omniauth-oauth2 (~> 1.8) - omniauth-google-oauth2 (1.1.1) - jwt (>= 2.0) - oauth2 (~> 2.0.6) - omniauth (~> 2.0) - omniauth-oauth2 (~> 1.8.0) - omniauth-microsoft-office365 (0.0.8) - omniauth - omniauth-oauth2 - omniauth-oauth2 (1.8.0) - oauth2 (>= 1.4, < 3) - omniauth (~> 2.0) - omniauth-rails_csrf_protection (1.0.1) - actionpack (>= 4.2) - omniauth (~> 2.0) openssl (3.2.0) orm_adapter (0.5.0) os (1.1.4) @@ -378,8 +348,6 @@ GEM nio4r (~> 2.0) racc (1.7.1) rack (2.2.8) - rack-protection (3.1.0) - rack (~> 2.2, >= 2.2.4) rack-proxy (0.7.6) rack rack-test (2.1.0) @@ -520,9 +488,6 @@ GEM simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) smart_properties (1.17.0) - snaky_hash (2.0.1) - hashie - version_gem (~> 1.1, >= 1.1.1) sqlite3 (1.6.3) mini_portile2 (~> 2.8.0) sqlite3 (1.6.3-arm64-darwin) @@ -543,7 +508,6 @@ GEM uber (0.1.0) unicode-display_width (2.5.0) uniform_notifier (1.16.0) - version_gem (1.1.3) warden (1.2.9) rack (>= 2.0.9) web-console (4.2.0) @@ -595,10 +559,6 @@ DEPENDENCIES lograge mysql2 oj - omniauth-github - omniauth-google-oauth2 - omniauth-microsoft-office365 - omniauth-rails_csrf_protection pagy pdf-reader pg diff --git a/app/controllers/api/templates_controller.rb b/app/controllers/api/templates_controller.rb index d1a851f6..2b6b1d59 100644 --- a/app/controllers/api/templates_controller.rb +++ b/app/controllers/api/templates_controller.rb @@ -58,7 +58,9 @@ module Api schema: [%i[attachment_uuid name]], submitters: [%i[name uuid]], fields: [[:uuid, :submitter_uuid, :name, :type, :required, :readonly, :default_value, - { options: [%i[value uuid]], areas: [%i[x y w h cell_w attachment_uuid option_uuid page]] }]] + { preferences: {}, + options: [%i[value uuid]], + areas: [%i[x y w h cell_w attachment_uuid option_uuid page]] }]] ) end end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb deleted file mode 100644 index de6d1910..00000000 --- a/app/controllers/omniauth_callbacks_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class OmniauthCallbacksController < Devise::OmniauthCallbacksController - def google_oauth2 - @user = Users.from_omniauth(request.env['omniauth.auth']) - - if @user.persisted? - flash[:notice] = I18n.t('devise.omniauth_callbacks.success', kind: 'Google') - - sign_in_and_redirect @user, event: :authentication - else - redirect_to new_registration_path(oauth_callback: true, user: @user.slice(:email, :first_name, :last_name)), - notice: 'Please complete registration with Google auth' - end - end -end diff --git a/app/javascript/application.js b/app/javascript/application.js index 30e626d2..178b3623 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -86,6 +86,7 @@ window.customElements.define('template-builder', class extends HTMLElement { backgroundColor: '#faf7f5', withPhone: this.dataset.withPhone === 'true', withLogo: this.dataset.withLogo !== 'false', + withPayment: this.dataset.withPayment !== 'false', acceptFileTypes: this.dataset.acceptFileTypes, isDirectUpload: this.dataset.isDirectUpload === 'true' }) diff --git a/app/javascript/form.js b/app/javascript/form.js index f0023ecf..601b45d0 100644 --- a/app/javascript/form.js +++ b/app/javascript/form.js @@ -10,7 +10,6 @@ window.customElements.define('submission-form', class extends HTMLElement { this.app = createApp(Form, { submitter: JSON.parse(this.dataset.submitter), - authenticityToken: this.dataset.authenticityToken, canSendEmail: this.dataset.canSendEmail === 'true', isDirectUpload: this.dataset.isDirectUpload === 'true', goToLast: this.dataset.goToLast === 'true', diff --git a/app/javascript/submission_form/area.vue b/app/javascript/submission_form/area.vue index 46e80dfd..9145900d 100644 --- a/app/javascript/submission_form/area.vue +++ b/app/javascript/submission_form/area.vue @@ -53,7 +53,7 @@ :src="initials.url" >
diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index 9439523c..399c43d4 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -301,6 +301,7 @@ export default { baseFetch: this.baseFetch, backgroundColor: this.backgroundColor, withPhone: this.withPhone, + withPayment: this.withPayment, selectedAreaRef: computed(() => this.selectedAreaRef) } }, @@ -369,6 +370,11 @@ export default { required: false, default: false }, + withPayment: { + type: Boolean, + required: false, + default: false + }, fetchOptions: { type: Object, required: false, @@ -436,6 +442,12 @@ export default { window.addEventListener('keydown', this.onKeyDown) window.addEventListener('resize', this.onWindowResize) + + this.$nextTick(() => { + if (document.location.search?.includes('stripe_connect_success')) { + document.querySelector('form[action="/auth/stripe_connect"]')?.closest('.dropdown')?.querySelector('label')?.focus() + } + }) }, unmounted () { document.removeEventListener('keyup', this.onKeyUp) diff --git a/app/javascript/template_builder/field.vue b/app/javascript/template_builder/field.vue index 27f4a0a9..c5285095 100644 --- a/app/javascript/template_builder/field.vue +++ b/app/javascript/template_builder/field.vue @@ -65,8 +65,12 @@ :stroke-width="1.6" /> +
  • diff --git a/app/mailers/submitter_mailer.rb b/app/mailers/submitter_mailer.rb index 0d339b78..2b7ec09e 100644 --- a/app/mailers/submitter_mailer.rb +++ b/app/mailers/submitter_mailer.rb @@ -100,7 +100,7 @@ class SubmitterMailer < ApplicationMailer attachments[submitter.submission.audit_trail.filename.to_s] = audit_trail_data if audit_trail_data - file_fields = submitter.submission.template_fields.select { |e| e['type'] == 'file' } + file_fields = submitter.submission.template_fields.select { |e| e['type'].in?(%w[file payment]) } if file_fields.pluck('submitter_uuid').uniq.size == 1 storage_attachments = diff --git a/app/models/user.rb b/app/models/user.rb index af0ecf31..40d7b884 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -59,10 +59,6 @@ class User < ApplicationRecord devise :two_factor_authenticatable, :recoverable, :rememberable, :validatable, :trackable - if Docuseal.multitenant? - devise :registerable, :omniauthable, omniauth_providers: %i[google_oauth2 microsoft_office365 github] - end - attribute :role, :string, default: ADMIN_ROLE attribute :uuid, :string, default: -> { SecureRandom.uuid } diff --git a/app/views/submissions/_value.html.erb b/app/views/submissions/_value.html.erb index f8bb3cac..52a030c8 100644 --- a/app/views/submissions/_value.html.erb +++ b/app/views/submissions/_value.html.erb @@ -1,7 +1,7 @@ <% if field['type'].in?(['signature', 'image', 'initials']) %> - <% elsif field['type'] == 'file' %> + <% elsif field['type'].in?(['file', 'payment']) %>
    <% Array.wrap(value).each do |val| %> diff --git a/app/views/submissions/show.html.erb b/app/views/submissions/show.html.erb index 4acddf15..03ead8ec 100644 --- a/app/views/submissions/show.html.erb +++ b/app/views/submissions/show.html.erb @@ -148,7 +148,7 @@
    <% elsif field['type'] == 'image' %> - <% elsif field['type'] == 'file' %> + <% elsif field['type'] == 'file' || field['type'] == 'payment' %>
    <% Array.wrap(value).each do |val| %> diff --git a/app/views/submit_form/_submission_form.html.erb b/app/views/submit_form/_submission_form.html.erb index d931c127..1ce29fe9 100644 --- a/app/views/submit_form/_submission_form.html.erb +++ b/app/views/submit_form/_submission_form.html.erb @@ -1,4 +1,4 @@ <% data_attachments = attachments_index.values.select { |e| e.record_id == submitter.id }.to_json(only: %i[uuid], methods: %i[url filename content_type]) %> <% data_fields = (submitter.submission.template_fields || submitter.submission.template.fields).select { |f| f['submitter_uuid'] == submitter.uuid }.to_json %> <% configs = Submitters::FormConfigs.call(submitter) %> - + diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index f082a7da..00d04479 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -14,7 +14,6 @@ Devise.otp_allowed_drift = 60.seconds # # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. -# rubocop:disable Metrics/BlockLength Devise.setup do |config| config.warden do |manager| manager.default_strategies(scope: :user).unshift(:two_factor_authenticatable) @@ -274,17 +273,6 @@ Devise.setup do |config| # The default HTTP method used to sign out a resource. Default is :delete. config.sign_out_via = :delete - # ==> OmniAuth - # Add a new OmniAuth provider. Check the wiki for more information on setting - # up on your models and hooks. - config.omniauth :google_oauth2, ENV.fetch('GOOGLE_CLIENT_ID', nil), ENV.fetch('GOOGLE_CLIENT_SECRET', nil), {} - config.omniauth :microsoft_office365, ENV.fetch('OFFICE365_CLIENT_ID', nil), - ENV.fetch('OFFICE365_CLIENT_SECRET', nil), {} - - if ENV['GITHUB_CLIENT_ID'] - config.omniauth :github, ENV.fetch('GITHUB_CLIENT_ID', nil), ENV.fetch('GITHUB_CLIENT_SECRET', nil), {} - end - # ==> Warden configuration # If you want to use other strategies, that are not supported by Devise, or # change the failure app, you can configure them inside the config.warden block. @@ -322,5 +310,6 @@ Devise.setup do |config| # When set to false, does not sign a user in automatically after their password is # changed. Defaults to true, so a user is signed in automatically after changing a password. # config.sign_in_after_change_password = true + + ActiveSupport.run_load_hooks(:devise_config, config) end -# rubocop:enable Metrics/BlockLength diff --git a/config/routes.rb b/config/routes.rb index f613641f..2cd89c48 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,7 +10,7 @@ Rails.application.routes.draw do path: '/', only: %i[sessions passwords omniauth_callbacks], controllers: begin options = { sessions: 'sessions', passwords: 'passwords' } - options[:omniauth_callbacks] = 'omniauth_callbacks' if Docuseal.multitenant? + options[:omniauth_callbacks] = 'omniauth_callbacks' if User.devise_modules.include?(:omniauthable) options end diff --git a/lib/submissions/generate_audit_trail.rb b/lib/submissions/generate_audit_trail.rb index f76b3ad0..2ac8a7e7 100644 --- a/lib/submissions/generate_audit_trail.rb +++ b/lib/submissions/generate_audit_trail.rb @@ -22,6 +22,12 @@ module Submissions VERIFIED_TEXT = 'Verified' UNVERIFIED_TEXT = 'Unverified' + CURRENCY_SYMBOLS = { + 'USD' => '$', + 'EUR' => '€', + 'GBP' => '£' + }.freeze + module_function # rubocop:disable Metrics @@ -200,7 +206,15 @@ module Submissions composer.image(io, width:, height:, margin: [0, 0, 10, 0]) composer.formatted_text_box([{ text: '' }]) - elsif field['type'] == 'file' + elsif field['type'].in?(%w[file payment]) + if field['type'] == 'payment' + unit = CURRENCY_SYMBOLS[field['preferences']['currency']] + + price = ApplicationController.helpers.number_to_currency(field['preferences']['price'], unit:) + + composer.formatted_text_box([{ text: "Paid #{price}\n" }], padding: [0, 0, 10, 0]) + end + composer.formatted_text_box( Array.wrap(value).map do |uuid| attachment = submitter.attachments.find { |a| a.uuid == uuid } diff --git a/lib/submissions/generate_result_attachments.rb b/lib/submissions/generate_result_attachments.rb index 497becaa..5015112b 100644 --- a/lib/submissions/generate_result_attachments.rb +++ b/lib/submissions/generate_result_attachments.rb @@ -85,7 +85,7 @@ module Submissions width: image.width * scale, height: image.height * scale ) - when 'file' + when 'file', 'payment' items = Array.wrap(value).each_with_object([]) do |uuid, acc| attachment = submitter.attachments.find { |a| a.uuid == uuid } diff --git a/lib/submitters/submit_values.rb b/lib/submitters/submit_values.rb index f3523d64..193f35e9 100644 --- a/lib/submitters/submit_values.rb +++ b/lib/submitters/submit_values.rb @@ -99,7 +99,7 @@ module Submitters def replace_default_variables(value, attrs, template, with_time: false) return if value.blank? - value.gsub(VARIABLE_REGEXP) do |e| + value.to_s.gsub(VARIABLE_REGEXP) do |e| case key = ::Regexp.last_match(1) when 'time' if with_time