mirror of https://github.com/docusealco/docuseal
Merge 2e0f3da247 into 6e2430e5a2
commit
93bb3dd19e
@ -0,0 +1,30 @@
|
||||
# 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
|
||||
Loading…
Reference in new issue