require 2fa placeholder

This commit is contained in:
Pete Matsyburka
2025-04-08 15:24:17 +03:00
parent 889fcad859
commit c4505e67f0
10 changed files with 135 additions and 26 deletions
+12 -12
View File
@@ -7,11 +7,11 @@ class SubmitFormController < ApplicationController
skip_before_action :authenticate_user!
skip_authorization_check
before_action :load_submitter, only: %i[show update completed]
CONFIG_KEYS = [].freeze
def show
@submitter = Submitter.find_by!(slug: params[:slug])
submission = @submitter.submission
return redirect_to submit_form_completed_path(@submitter.slug) if @submitter.completed_at?
@@ -50,26 +50,24 @@ class SubmitFormController < ApplicationController
end
def update
submitter = Submitter.find_by!(slug: params[:slug])
if submitter.completed_at?
if @submitter.completed_at?
return render json: { error: I18n.t('form_has_been_completed_already') }, status: :unprocessable_entity
end
if submitter.template.archived_at? || submitter.submission.archived_at?
if @submitter.template.archived_at? || @submitter.submission.archived_at?
return render json: { error: I18n.t('form_has_been_archived') }, status: :unprocessable_entity
end
if submitter.submission.expired?
if @submitter.submission.expired?
return render json: { error: I18n.t('form_has_been_expired') }, status: :unprocessable_entity
end
if submitter.declined_at?
if @submitter.declined_at?
return render json: { error: I18n.t('form_has_been_declined') },
status: :unprocessable_entity
end
Submitters::SubmitValues.call(submitter, params, request)
Submitters::SubmitValues.call(@submitter, params, request)
head :ok
rescue Submitters::SubmitValues::RequiredFieldError => e
@@ -80,14 +78,16 @@ class SubmitFormController < ApplicationController
render json: { error: e.message }, status: :unprocessable_entity
end
def completed
@submitter = Submitter.completed.find_by!(slug: params[:submit_form_slug])
end
def completed; end
def success; end
private
def load_submitter
@submitter = Submitter.find_by!(slug: params[:slug] || params[:submit_form_slug])
end
def build_attachments_index(submission)
ActiveStorage::Attachment.where(record: submission.submitters, name: :attachments)
.preload(:blob).index_by(&:uuid)