diff --git a/Gemfile b/Gemfile index 200e84a6..ceba679f 100644 --- a/Gemfile +++ b/Gemfile @@ -15,9 +15,6 @@ gem 'csv', require: false gem 'csv-safe', require: false gem 'devise' gem 'devise-two-factor' -gem 'omniauth', '~> 2.1' -gem 'omniauth-google-oauth2', '~> 1.2' -gem 'omniauth-rails_csrf_protection', '~> 1.0' gem 'dotenv', require: false gem 'email_typo' gem 'faraday' @@ -29,6 +26,9 @@ gem 'jwt', require: false gem 'lograge' gem 'numo-narray-alt', require: false gem 'oj' +gem 'omniauth', '~> 2.1' +gem 'omniauth-google-oauth2', '~> 1.2' +gem 'omniauth-rails_csrf_protection', '~> 1.0' gem 'onnxruntime', require: false gem 'pagy' gem 'pg', require: false diff --git a/app/controllers/account_logo_controller.rb b/app/controllers/account_logo_controller.rb index e3b69bd0..74bed15b 100644 --- a/app/controllers/account_logo_controller.rb +++ b/app/controllers/account_logo_controller.rb @@ -7,8 +7,12 @@ class AccountLogoController < ApplicationController file = params[:logo] return reject('Choose a file to upload.') if file.blank? || !file.respond_to?(:content_type) - return reject('Logo must be a PNG, JPEG, or SVG image.') unless Account::LOGO_CONTENT_TYPES.include?(file.content_type) - return reject("Logo must be under #{Account::LOGO_MAX_BYTES / 1.megabyte} MB.") if file.size > Account::LOGO_MAX_BYTES + unless Account::LOGO_CONTENT_TYPES.include?(file.content_type) + return reject('Logo must be a PNG, JPEG, or SVG image.') + end + if file.size > Account::LOGO_MAX_BYTES + return reject("Logo must be under #{Account::LOGO_MAX_BYTES / 1.megabyte} MB.") + end safe = AccountLogo.sanitize_upload(file) current_account.logo.attach(io: safe.io, filename: safe.filename, content_type: safe.content_type) diff --git a/app/controllers/embed_scripts_controller.rb b/app/controllers/embed_scripts_controller.rb index 5a964d81..5a9bf9ff 100644 --- a/app/controllers/embed_scripts_controller.rb +++ b/app/controllers/embed_scripts_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class EmbedScriptsController < ActionController::Metal - DUMMY_SCRIPT = <<~JAVASCRIPT.freeze + DUMMY_SCRIPT = <<~JAVASCRIPT const DummyBuilder = class extends HTMLElement { connectedCallback() { this.innerHTML = ` diff --git a/app/models/user.rb b/app/models/user.rb index 01c944eb..9a81355e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -140,8 +140,9 @@ class User < ApplicationRecord end def self.from_google_omniauth(auth) - hd = auth.extra&.raw_info&.respond_to?(:hd) ? auth.extra.raw_info.hd : auth.extra&.raw_info&.dig('hd') - return nil unless Wabosign.google_domain_allowed?(hd) + raw_info = auth.extra&.raw_info + hosted_domain = raw_info.respond_to?(:hd) ? raw_info.hd : raw_info&.dig('hd') + return nil unless Wabosign.google_domain_allowed?(hosted_domain) email = auth.info.email.to_s.downcase return nil if email.blank? @@ -172,15 +173,12 @@ class User < ApplicationRecord def self.default_sso_account # ENV override always wins. - if Wabosign::GOOGLE_DEFAULT_ACCOUNT_ID.present? - return Account.find_by(id: Wabosign::GOOGLE_DEFAULT_ACCOUNT_ID) - end + return Account.find_by(id: Wabosign::GOOGLE_DEFAULT_ACCOUNT_ID) if Wabosign::GOOGLE_DEFAULT_ACCOUNT_ID.present? # If an admin saved the Google SSO config via the UI, JIT-provision into # that same account so admins land in the right tenant. - if (db_config = EncryptedConfig.find_by(key: EncryptedConfig::GOOGLE_SSO_KEY)) - return db_config.account if db_config.account && db_config.account.archived_at.nil? - end + db_config = EncryptedConfig.find_by(key: EncryptedConfig::GOOGLE_SSO_KEY) + return db_config.account if db_config&.account && db_config.account.archived_at.nil? Account.order(:created_at).first end diff --git a/app/views/personalization_settings/_logo_form.html.erb b/app/views/personalization_settings/_logo_form.html.erb index 1740e7e8..09d13d96 100644 --- a/app/views/personalization_settings/_logo_form.html.erb +++ b/app/views/personalization_settings/_logo_form.html.erb @@ -8,8 +8,8 @@ <%= current_account.logo.filename %> <%= button_to 'Remove', settings_account_logo_path, method: :delete, - class: 'btn btn-sm btn-outline btn-error', - data: { turbo_confirm: 'Remove the uploaded logo?' } %> + class: 'btn btn-sm btn-outline btn-error', + data: { turbo_confirm: 'Remove the uploaded logo?' } %> <% end %> diff --git a/app/views/shared/_account_logo.html.erb b/app/views/shared/_account_logo.html.erb index dcc039d9..69895a79 100644 --- a/app/views/shared/_account_logo.html.erb +++ b/app/views/shared/_account_logo.html.erb @@ -3,10 +3,8 @@ account: (optional) an Account record class: CSS class string forwarded to / width: pixel width (default 37) - height: pixel height (default 37) -%> -<% - acc = local_assigns[:account] + height: pixel height (default 37) %> +acc = local_assigns[:account] klass = local_assigns[:class] w = local_assigns.fetch(:width, '37') h = local_assigns.fetch(:height, '37') diff --git a/app/views/sms_settings/index.html.erb b/app/views/sms_settings/index.html.erb index f572f851..de767ce6 100644 --- a/app/views/sms_settings/index.html.erb +++ b/app/views/sms_settings/index.html.erb @@ -39,7 +39,7 @@
<%= ff.label :provider, 'Provider', class: 'label' %> - <%= ff.select :provider, [['BulkVS', 'bulkvs']], { selected: value['provider'] || 'bulkvs' }, class: 'base-select' %> + <%= ff.select :provider, [%w[BulkVS bulkvs]], { selected: value['provider'] || 'bulkvs' }, class: 'base-select' %>
<%= ff.label :basic_auth_token, 'BulkVS Basic Auth Token', class: 'label' %> @@ -73,7 +73,7 @@ <%= form_with url: test_message_settings_sms_path, method: :post, html: { autocomplete: 'off', class: 'space-y-3' } do |f| %>
- + A short test message is sent to this number using your saved config.
diff --git a/app/views/sso_settings/index.html.erb b/app/views/sso_settings/index.html.erb index 83f70bfb..0eaf0562 100644 --- a/app/views/sso_settings/index.html.erb +++ b/app/views/sso_settings/index.html.erb @@ -37,7 +37,11 @@

Google SSO is not configured

Fill in your Google Cloud OAuth client details below. The OAuth redirect URI to register in Google Cloud Console is - <%= "#{root_url}auth/google_oauth2/callback" rescue '/auth/google_oauth2/callback' %>. + <%= begin + "#{root_url}auth/google_oauth2/callback" + rescue StandardError + '/auth/google_oauth2/callback' + end %>.

diff --git a/app/views/templates/_embedding.html.erb b/app/views/templates/_embedding.html.erb index 7f57fe9b..5000973d 100644 --- a/app/views/templates/_embedding.html.erb +++ b/app/views/templates/_embedding.html.erb @@ -55,8 +55,8 @@
- <%= link_to t(:learn_more), "#{Wabosign::PRODUCT_URL}/docs/embedding", target: "_blank", data: { turbo: false }, class: "btn btn-ghost text-gray-100 flex", rel: "noopener" %> - "> + <%= link_to t(:learn_more), "#{Wabosign::PRODUCT_URL}/docs/embedding", target: '_blank', data: { turbo: false }, class: 'btn btn-ghost text-gray-100 flex', rel: 'noopener' %> + @@ -78,7 +78,7 @@ -
<script src="<%= embed_script_url(filename: "form.js") %>"></script>
+      
<script src="<%= embed_script_url(filename: 'form.js') %>"></script>
 
 <docuseal-form data-src="<%= start_form_url(slug: template.slug) %>"></docuseal-form>
 
@@ -88,7 +88,7 @@