Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/api/active_storage_blobs_proxy_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def show
blob_uuid, purp, exp = ApplicationRecord.signed_id_verifier.verified(params[:signed_uuid])

if blob_uuid.blank? || purp != 'blob'
Rollbar.error('Blob not found') if defined?(Rollbar)
Rails.logger.error('Blob not found')

return head :not_found
end
Expand Down Expand Up @@ -57,7 +57,7 @@ def authorization_check!(attachment, record, exp)
return if !require_ttl && !require_auth
end

Rollbar.error('Blob unauthorized') if defined?(Rollbar)
Rails.logger.error('Blob unauthorized')

raise CanCan::AccessDenied
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ActiveStorageBlobsProxyLegacyController < ApiBaseController

# rubocop:disable Metrics
def show
Rollbar.info('Blob legacy') if defined?(Rollbar)
Rails.logger.info('Blob legacy')

blob = ActiveStorage::Blob.find_signed(params[:signed_blob_id] || params[:signed_id])

Expand All @@ -25,7 +25,7 @@ def show
end

unless is_permitted
Rollbar.error("Blob account not found: #{blob.id}") if defined?(Rollbar)
Rails.logger.error("Blob account not found: #{blob.id}")

return render json: { error: 'Not authenticated' }, status: :unauthorized
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/api_base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ApiBaseController < ActionController::API
end

rescue_from RateLimit::LimitApproached do |e|
Rollbar.error(e) if defined?(Rollbar)
Rails.logger.error(e)

render json: { error: 'Too many requests' }, status: :too_many_requests
end
Expand All @@ -31,7 +31,7 @@ class ApiBaseController < ActionController::API
end

rescue_from JSON::ParserError do |e|
Rollbar.warning(e) if defined?(Rollbar)
Rails.logger.warn(e)

render json: { error: "JSON parse error: #{e.message}" }, status: :unprocessable_content
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/attachments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ def create
image = Vips::Image.new_from_file(params[:file].path)

if ImageUtils.blank?(image)
Rollbar.error("Empty signature: #{submitter.id}") if defined?(Rollbar)
Rails.logger.error("Empty signature: #{submitter.id}")

return render json: { error: "#{params[:type]} is empty" }, status: :unprocessable_content
end

if ImageUtils.error?(image)
Rollbar.error("Error signature: #{submitter.id}") if defined?(Rollbar)
Rails.logger.error("Error signature: #{submitter.id}")

return render json: { error: "#{params[:type]} error, try to sign on another device" },
status: :unprocessable_content
Expand All @@ -35,7 +35,7 @@ def create

render json: attachment.as_json(only: %i[uuid created_at], methods: %i[url filename content_type])
rescue Submitters::MaliciousFileExtension => e
Rollbar.error(e) if defined?(Rollbar)
Rails.logger.error(e)

render json: { error: e.message }, status: :unprocessable_content
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def create
return render json: { error: 'Template not found' }, status: :unprocessable_content if @template.nil?

if @template.fields.blank?
Rollbar.warning("Template does not contain fields: #{@template.id}") if defined?(Rollbar)
Rails.logger.warn("Template does not contain fields: #{@template.id}")

return render json: { error: 'Template does not contain fields' }, status: :unprocessable_content
end
Expand All @@ -82,7 +82,7 @@ def create
render json: build_create_json(submissions)
rescue Submitters::NormalizeValues::BaseError, Submissions::CreateFromSubmitters::BaseError,
DownloadUtils::UnableToDownload => e
Rollbar.warning(e) if defined?(Rollbar)
Rails.logger.warn(e)

render json: { error: e.message }, status: :unprocessable_content
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/submitters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def update
render json: Submitters::SerializeForApi.call(@submitter, with_template: false, with_urls: true,
with_events: false, params:)
rescue Submitters::NormalizeValues::BaseError, DownloadUtils::UnableToDownload => e
Rollbar.warning(e) if defined?(Rollbar)
Rails.logger.warn(e)

render json: { error: e.message }, status: :unprocessable_content
end
Expand Down
14 changes: 3 additions & 11 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,20 @@ class ApplicationController < ActionController::Base
end

rescue_from RateLimit::LimitApproached do |e|
Rollbar.error(e) if defined?(Rollbar)
Rails.logger.error(e)

redirect_to request.referer, alert: 'Too many requests', status: :too_many_requests
end

if Rails.env.production? || Rails.env.test?
rescue_from CanCan::AccessDenied do |e|
Rollbar.warning(e) if defined?(Rollbar)
Rails.logger.warn(e)

redirect_to root_path, alert: e.message
end
end

def default_url_options
if request.domain == 'docuseal.com'
return { host: 'docuseal.com', protocol: ENV['FORCE_SSL'].present? ? 'https' : 'http' }
end

Docuseal.default_url_options
end

Expand Down Expand Up @@ -125,11 +121,7 @@ def form_link_host
Docuseal.default_url_options[:host]
end

def maybe_redirect_com
return if request.domain != 'docuseal.co'

redirect_to request.url.gsub('.co/', '.com/'), allow_other_host: true, status: :moved_permanently
end
def maybe_redirect_com; end

def set_csp
request.content_security_policy = current_content_security_policy.tap do |policy|
Expand Down
18 changes: 1 addition & 17 deletions app/controllers/console_redirect_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,6 @@ class ConsoleRedirectController < ApplicationController
skip_authorization_check

def index
if request.path == '/upgrade'
params[:redir] = Docuseal.multitenant? ? "#{Docuseal::CONSOLE_URL}/plans" : "#{Docuseal::CONSOLE_URL}/on_premises"
end

params[:redir] = "#{Docuseal::CONSOLE_URL}/manage" if request.path == '/manage'

return redirect_to(new_user_session_path({ redir: params[:redir] }.compact)) if true_user.blank?

auth = JsonWebToken.encode(uuid: true_user.uuid,
scope: :console,
exp: 1.minute.from_now.to_i)

redir_uri = Addressable::URI.parse(params[:redir])
path = redir_uri.path if params[:redir].to_s.starts_with?(Docuseal::CONSOLE_URL)

redirect_to "#{Docuseal::CONSOLE_URL}#{path}?#{{ **redir_uri&.query_values, 'auth' => auth }.to_query}",
allow_other_host: true
redirect_to root_path
end
end
10 changes: 2 additions & 8 deletions app/controllers/embed_scripts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# frozen_string_literal: true

class EmbedScriptsController < ActionController::Metal
DUMMY_SCRIPT = <<~JAVASCRIPT.freeze
DUMMY_SCRIPT = <<~JAVASCRIPT
const DummyBuilder = class extends HTMLElement {
connectedCallback() {
this.innerHTML = `
<div style="text-align: center; padding: 20px; font-family: Arial, sans-serif;">
<h2>Upgrade to Pro</h2>
<p>Unlock embedded components by upgrading to Pro</p>
<div style="margin-top: 40px;">
<a href="#{Docuseal::CONSOLE_URL}/on_premises" target="_blank" style="padding: 15px 25px; background-color: #222; color: white; text-decoration: none; border-radius: 5px; font-size: 16px; cursor: pointer;">
Learn More
</a>
</div>
<p>Embedded components are not available in this installation.</p>
</div>
`;
}
Expand Down
12 changes: 0 additions & 12 deletions app/controllers/enquiries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ class EnquiriesController < ApplicationController
skip_authorization_check

def create
if params[:talk_to_sales] == 'on'
Faraday.post(Docuseal::ENQUIRIES_URL,
enquiry_params.merge(type: :talk_to_sales).to_json,
'Content-Type' => 'application/json')
end

head :ok
end

private

def enquiry_params
params.require(:user).permit(:email)
end
end
22 changes: 0 additions & 22 deletions app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
# frozen_string_literal: true

class ErrorsController < ActionController::Base
ENTERPRISE_FEATURE_MESSAGE =
'This feature is available in Pro Edition: https://www.docuseal.com/pricing'

ENTERPRISE_PATHS = [
'/submissions/html',
'/api/submissions/html',
'/templates/html',
'/api/templates/html',
'/submissions/pdf',
'/api/submissions/pdf',
'/templates/pdf',
'/api/templates/pdf',
'/templates/doc',
'/api/templates/doc',
'/templates/docx',
'/api/templates/docx'
].freeze

SAFE_ERROR_MESSAGE_CLASSES = [
ActionDispatch::Http::Parameters::ParseError,
JSON::ParserError
].freeze

def show
if request.original_fullpath.in?(ENTERPRISE_PATHS) && error_status_code == 404
return render json: { status: 404, message: ENTERPRISE_FEATURE_MESSAGE }, status: :not_found
end

respond_to do |f|
f.json do
set_cors_headers
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/esign_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create

redirect_to settings_esign_path, notice: I18n.t('certificate_has_been_successfully_added')
rescue OpenSSL::PKCS12::PKCS12Error => e
Rollbar.error(e) if defined?(Rollbar)
Rails.logger.error(e)

@cert_record.errors.add(:password, e.message)

Expand Down
10 changes: 0 additions & 10 deletions app/controllers/newsletters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ class NewslettersController < ApplicationController
def show; end

def update
Faraday.post(Docuseal::NEWSLETTER_URL, newsletter_params.to_json, 'Content-Type' => 'application/json')
rescue StandardError => e
Rails.logger.error(e)
ensure
redirect_to root_path
end

private

def newsletter_params
params.require(:user).permit(:email)
end
end
3 changes: 2 additions & 1 deletion app/controllers/personalization_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class PersonalizationSettingsController < ApplicationController
AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY,
AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY,
AccountConfig::FORM_COMPLETED_MESSAGE_KEY,
*(Docuseal.multitenant? ? [] : [AccountConfig::POLICY_LINKS_KEY])
*(Docuseal.multitenant? ? [] : [AccountConfig::POLICY_LINKS_KEY]),
AccountConfig::COMPANY_LOGO_URL_KEY
].freeze

InvalidKey = Class.new(StandardError)
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def create
email = sign_in_params[:email].to_s.downcase

if Docuseal.multitenant? && !User.exists?(email:)
Rollbar.warning('Sign in new user') if defined?(Rollbar)
Rails.logger.warn('Sign in new user')

return redirect_to new_registration_path(sign_up: true, user: sign_in_params.slice(:email)),
notice: I18n.t('create_a_new_account')
Expand All @@ -25,11 +25,7 @@ def create
private

def after_sign_in_path_for(...)
if params[:redir].present?
return console_redirect_index_path(redir: params[:redir]) if params[:redir].starts_with?(Docuseal::CONSOLE_URL)

return params[:redir]
end
return params[:redir] if params[:redir].present?

super
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/start_form_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def show
@template.submitters.first)['uuid'])
render :email_verification if params[:email_verification]
else
Rollbar.warning("Not shared template: #{@template.id}") if defined?(Rollbar)
Rails.logger.warn("Not shared template: #{@template.id}")

return render :private if current_user && current_ability.can?(:read, @template)

Expand Down Expand Up @@ -111,7 +111,7 @@ def authorize_start!
return if @resubmit_submitter
return if @template.shared_link? || (current_user && current_ability.can?(:read, @template))

Rollbar.warning("Not shared template: #{@template.id}") if defined?(Rollbar)
Rails.logger.warn("Not shared template: #{@template.id}")

redirect_to start_form_path(@template.slug)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/submissions_download_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def index
Submissions::EnsureResultGenerated.call(last_submitter)

if last_submitter.completed_at < TTL.ago && !signature_valid && !current_user_submitter?(last_submitter)
Rollbar.info("TTL: #{last_submitter.id}") if defined?(Rollbar)
Rails.logger.info("TTL: #{last_submitter.id}")

return head :not_found
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/submissions_preview_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def show
end

if use_signature?(@submission) && !signature_valid
Rollbar.info("TTL: #{@submission.id}") if defined?(Rollbar)
Rails.logger.info("TTL: #{@submission.id}")

return redirect_to submissions_preview_completed_path(@submission.slug)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/submit_form_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def update

head :ok
rescue Submitters::SubmitValues::RequiredFieldError => e
Rollbar.warning("Required field #{@submitter.id}: #{e.message}") if defined?(Rollbar)
Rails.logger.warn("Required field #{@submitter.id}: #{e.message}")

render json: { field_uuid: e.message }, status: :unprocessable_content
rescue Submitters::SubmitValues::ValidationError => e
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/submitters_send_email_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def create
if Docuseal.multitenant? && SubmissionEvent.exists?(submitter: @submitter,
event_type: 'send_email',
created_at: 10.hours.ago..Time.current)
Rollbar.warning("Already sent: #{@submitter.id}") if defined?(Rollbar)
Rails.logger.warn("Already sent: #{@submitter.id}")

return redirect_back(fallback_location: submission_path(@submitter.submission),
alert: I18n.t('email_has_been_sent_already'))
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/templates_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def create
rescue Templates::CreateAttachments::PdfEncrypted
render turbo_stream: turbo_stream.append(params[:form_id], html: helpers.tag.prompt_password)
rescue StandardError => e
Rollbar.error(e) if defined?(Rollbar)
Rails.logger.error(e)

raise if Rails.env.local?

Expand Down
Loading
Loading