You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/app/controllers/submitters_reset_signature_...

31 lines
1.1 KiB

# frozen_string_literal: true
class SubmittersResetSignatureController < ApplicationController
load_and_authorize_resource :submitter, parent: false
def update
authorize!(:update, @submitter)
if @submitter.completed_at.blank?
return redirect_back(fallback_location: submission_path(@submitter.submission),
alert: I18n.t('signature_has_not_been_completed_yet'))
end
# Remove the previously generated signature artifacts.
@submitter.documents.purge
@submitter.attachments.purge
@submitter.preview_documents.purge
# Re-open the submitter's form so they can sign again from scratch.
@submitter.update!(completed_at: nil, opened_at: nil, declined_at: nil, values: {})
# Email the signer a fresh invitation to correct their signature.
SendSubmitterInvitationEmailJob.perform_async('submitter_id' => @submitter.id)
@submitter.update!(sent_at: Time.current)
redirect_back(fallback_location: submission_path(@submitter.submission),
notice: I18n.t('correction_request_has_been_sent'))
end
end