Login Form

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

Heres a basic one which could be located at enact/template/login.html and accessed via yoursite.com/login.

{% extends “_layout.html” %}

{% do enact.view.title('Login | ' ~ enact.siteName ) %}

{% block content %}

    {% if enact.currentUser %}
        {{ enact.view.redirect( cpSlug( enact.config('afterLoginRedirectSlug') ) ) }}
    {% endif %}

    <h1>Login</h1>
    <a href='/forgot-password'>Forgot your password?</a>

    <form method='post'>
        <input type='hidden' name='enactAction' value='login'/>
        {{ enact.csrfTokenInput }}
        <label>Username/Email</label>
        <input type='text name='password' required/>
        <label>Password</label>
        <input type='password' name='password required/>
        <input type='checkbox' name='remember'/>
        <label>Remember Me</label>

        <hr>

        <input type='submit' value='Login'/>

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

    </form>

{% 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) Set to true if the login was successful, or a string describing why not; either 'Invalid login credentials', or 'Your doing that to much, please try again in x minutes', where x minutes is based on the config setting maxLoginAttemptsLockOutSeconds.

  • e – (for error) Set to true when user could not be logged in, false if log in was successful.

If you want users to be redirected by to your custom login page after they logout you should set the configuration setting afterLogoutRedirectSlug to point the slug of your custom login page, in this case you would set it to /login. You should always begin it with a slash indicating the slug is not contained within the admin control panel.