Class FormEmailVerificationProcessor
java.lang.Object
sk.iway.iwcm.components.multistep_form.support.FormEmailVerificationProcessor
- All Implemented Interfaces:
FormProcessorInterface
@Component
public class FormEmailVerificationProcessor
extends Object
implements FormProcessorInterface
Processor that handles email verification for multi-step forms.
Responsibilities:
- After step 1, generates a verification code and sends it to the user's email.
- During step 2, validates the code provided by the user and manages attempt limits.
Session keys are namespaced per form to avoid collisions between multiple forms processed in the same session.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanhandleFormSave(String formName, FormSettingsEntity formSettings, Integer iLastDocId, jakarta.servlet.http.HttpServletRequest request) Performs custom final save logic for the form.voidrunStepInterceptor(String formName, FormSettingsEntity formSettings, FormStepEntity stepEntity, org.json.JSONObject stepData, jakarta.servlet.http.HttpServletRequest request, Map<String, String> errors) Intercepts form processing to trigger email verification after the first step.voidvalidateStep(String formName, FormSettingsEntity formSettings, FormStepEntity stepEntity, org.json.JSONObject stepData, jakarta.servlet.http.HttpServletRequest request, Map<String, String> errors) Validates the email verification code during the second step.
-
Field Details
-
SESSION_VERIFY_CODE_KEY
- See Also:
-
SESSION_VERIFY_CODE_ATTEMPTS_KEY
- See Also:
-
-
Constructor Details
-
FormEmailVerificationProcessor
public FormEmailVerificationProcessor()
-
-
Method Details
-
runStepInterceptor
public void runStepInterceptor(String formName, FormSettingsEntity formSettings, FormStepEntity stepEntity, org.json.JSONObject stepData, jakarta.servlet.http.HttpServletRequest request, Map<String, String> errors) throws SaveFormExceptionIntercepts form processing to trigger email verification after the first step.- Specified by:
runStepInterceptorin interfaceFormProcessorInterface- Parameters:
formName- the unique form nameformSettings- settings already loaded for the current form and domainstepEntity- the current form step being processedstepData- JSON payload containing fields submitted in the current steprequest- current HTTP requesterrors- map to collect validation errors (not used in this step)- Throws:
SaveFormException- if email cannot be determined or email sending fails
-
validateStep
public void validateStep(String formName, FormSettingsEntity formSettings, FormStepEntity stepEntity, org.json.JSONObject stepData, jakarta.servlet.http.HttpServletRequest request, Map<String, String> errors) throws SaveFormExceptionValidates the email verification code during the second step.If the code is invalid, the error is placed into the
errorsmap for the corresponding field. If the maximum number of attempts is reached, aSaveFormExceptionis thrown to interrupt the processing and redirect to an error page.- Specified by:
validateStepin interfaceFormProcessorInterface- Parameters:
formName- the unique form nameformSettings- settings already loaded for the current form and domainstepEntity- the current form step being validatedstepData- JSON payload containing fields submitted in the current steprequest- current HTTP requesterrors- map to collect validation errors when the code is invalid- Throws:
SaveFormException- when the verification field is missing or the maximum number of attempts is reached
-
handleFormSave
public boolean handleFormSave(String formName, FormSettingsEntity formSettings, Integer iLastDocId, jakarta.servlet.http.HttpServletRequest request) throws SaveFormException, IOException Description copied from interface:FormProcessorInterfacePerforms custom final save logic for the form. The return value controls whether the default WebJET save mechanism is executed.- Specified by:
handleFormSavein interfaceFormProcessorInterface- Parameters:
formName- logical identifier of the formformSettings- configuration of the form used during savingiLastDocId- last document ID (if any) associated with the submissionrequest- current HTTP request for context and additional data- Returns:
trueto continue with the default WebJET save;falseto skip it- Throws:
SaveFormException- for functional errors during saveIOException- for I/O related problems that occur during save
-