Exemplo n.º 1
0
def send_confirmation_email(session_store, schema):
    try:
        confirmation_email = ConfirmationEmail(
            session_store, schema, serialised_email=request.args.get("email"))
    except (ConfirmationEmailLimitReached, ConfirmationEmailNotEnabled):
        return redirect(url_for(".get_thank_you"))

    if request.method == "POST":
        if confirmation_email.form.validate():
            return redirect(
                url_for(
                    ".confirm_confirmation_email",
                    email=confirmation_email.get_url_safe_serialized_email(),
                ))

        logger.info(
            "email validation error",
            error_message=str(confirmation_email.form.errors["email"][0]),
        )

    return render_template(
        template="confirmation-email",
        content=confirmation_email.get_context(),
        hide_sign_out_button=True,
        page_title=confirmation_email.get_page_title(),
    )
    def __init__(
        self,
        schema: QuestionnaireSchema,
        session_store: SessionStore,
        serialized_email,
        form_data: Mapping,
    ):

        if not ConfirmationEmail.is_enabled(schema):
            raise ConfirmationEmailNotEnabled

        if ConfirmationEmail.is_limit_reached(session_store.session_data):
            raise ConfirmationEmailLimitReached

        self._serialized_email = serialized_email

        try:
            email = url_safe_serializer().loads(self._serialized_email)
        except BadSignature:
            raise BadRequest

        self._schema = schema
        self._session_store = session_store
        self._form_data = form_data
        self._email = email
        self.page_title = lazy_gettext("Confirm your email address")
Exemplo n.º 3
0
def get_confirmation_email_sent(session_store, schema):
    if not session_store.session_data.confirmation_email_count:
        raise NotFound

    try:
        email = url_safe_serializer().loads(request.args["email"])
    except BadSignature:
        raise BadRequest

    show_send_another_email_guidance = not ConfirmationEmail.is_limit_reached(
        session_store.session_data)
    show_feedback_call_to_action = Feedback.is_enabled(
        schema) and not Feedback.is_limit_reached(session_store.session_data)

    return render_template(
        template="confirmation-email-sent",
        content={
            "email":
            email,
            "send_confirmation_email_url":
            url_for("post_submission.send_confirmation_email"),
            "hide_sign_out_button":
            False,
            "show_send_another_email_guidance":
            show_send_another_email_guidance,
            "sign_out_url":
            url_for("session.get_sign_out"),
            "show_feedback_call_to_action":
            show_feedback_call_to_action,
        },
    )
Exemplo n.º 4
0
    def _get_confirmation_email(self):
        if not self._schema.get_submission().get("confirmation_email"):
            return None

        try:
            return ConfirmationEmail(self.PAGE_TITLE)
        except ConfirmationEmailLimitReached:
            return None
def get_confirmation_email_sent():
    if not get_session_store().session_data.confirmation_email_count:
        raise NotFound

    email = URLParamSerializer().loads(request.args.get("email"))

    return render_template(
        template="confirmation-email-sent",
        content={
            "email":
            email,
            "send_confirmation_email_url":
            url_for("post_submission.send_confirmation_email"),
            "hide_signout_button":
            False,
            "show_send_another_email_guidance":
            not ConfirmationEmail.is_limit_reached(),
            "sign_out_url":
            url_for("session.get_sign_out"),
        },
    )
def send_confirmation_email():
    if not get_session_store().session_data.confirmation_email_count:
        raise NotFound

    try:
        confirmation_email = ConfirmationEmail()
    except ConfirmationEmailLimitReached:
        return redirect(url_for("post_submission.get_thank_you"))

    if request.method == "POST" and confirmation_email.form.validate():
        confirmation_email.handle_post()
        return redirect(
            url_for(
                "post_submission.get_confirmation_email_sent",
                email=confirmation_email.get_url_safe_serialized_email(),
            ))

    return render_template(
        template="confirmation-email",
        content=confirmation_email.get_context(),
        hide_signout_button=True,
        page_title=confirmation_email.get_page_title(),
    )
 def confirmation_email(self):
     try:
         return ConfirmationEmail(self._session_store, self._schema,
                                  self.PAGE_TITLE)
     except (ConfirmationEmailNotEnabled, ConfirmationEmailLimitReached):
         return None