Account Activation Form

If your using Enact Client Edition you can provide your own account activation page.

Before you can provide your own account activation form you will need to :

Set the configuration setting accountActivationSlug to point the the slug where you are providing the form. In this case we will set it with a value of /activate-account. You should always begin it with a slash indicating the slug is not contained within the admin control panel. This is done so the email that is sent to the user contains the proper slug in the link.

Create a route to handle getting and posting the form. You have to create a route because a token will be added to your custom accountActivationSlug which acts as verification that the system generated the account activation link and establishes the user the account activation will be taking place for. So the slug emailed to the user who is being activated will looks like /activate-account/{some long token value}. Your route should be set up like so:

  • Type - ANY

  • Slug - /activate-account/{token}

  • Slug Variables - token - alpha_numeric

  • Action - _activate-account.html

Heres a basic one which could be located at enact/template/_activate-account.html

{% extends "_layout.html" %}

{% block content %}

    <h1>Activate Your Account</h1>

    {% if enact.session.hasFlash('accountActivationSuccess') %}
        <div class='alert-box success'>Your account has been activated! Click <a href='/login'>here to login</a>.</div>
    {% else %}

        <form method='post'>

            {{ enact.csrfTokenInput }}
            <input type='hidden' name='enactAction' value='postAccountActivation'/>

            <label>Create Password</label>
            <input type='password' name='password' required/>

            <label>Confirm Password</label>
            <input type='password' name='confirm_password' required/>

            <input type='submit' value='Activate Account'/>

            {% if enact.session.hasFlash('accountActivationError') %}
                <div class='alert-box warning'>{{ enact.session.getFlash('accountActivationError') }}</div>
            {% endif %}


    {% endif %}

{% endblock %}

Want to do AJAX?

Include the variable ajax in the POST data and you will get a JSON response back that looks like:

  • d – (for data) Either true for success, or a string describing the error.

  • e – (for error) Will be a truthy value if the account could not be activated, with the d containing the message as to why.