0

We have a page where a user may use one form to login to their Craft account on the front end - and one form where they can create and account. See the page here: https://www.cadex.com/shop/account/login/

And the template code here:

        <div class="login">
            <h1>Login To Your Account</h1>
            <div class="intro">
                Please login to your account below.
            </div>

            {% if craft.request.getSegment(3) == "logged-out" %}
                <div class="confirmMsg remove">You have been logged out of your account.</div>
            {% endif %}

            {% if craft.request.getSegment(3) == "password" %}
                <div class="confirmMsg remove">Your password has been successfully reset.</div>
            {% endif %}

            <form id="loginForm" method="post" accept-charset="UTF-8">
                {% if errorMessage is defined %}
                    <div class="errorMsg">{{ errorMessage }}</div>
                {% endif %}
                <input type="hidden" name="action" value="users/login">
                {{ getCsrfInput() }}
                <div class="input">
                    <label>Email <span>*</span></label>
                    <input placeholder="Email" name="loginName" value="" data-parsley-type="email" data-parsley-required="true">
                </div>
                <div class="input">
                    <label>Password <span>*</span></label>
                    <input type="password" placeholder="Password" name="password" value="" data-parsley-required="true">
                </div>
                <footer>
                    <button type="submit">Login</button>
                    <a href="{{ siteUrl }}account/reset-request">Forgot Password?</a>
                </footer>
            </form>
        </div>

        <div class="create">
            <h2>Don't Have An Account?</h2>
            <div class="intro">
                Create an account below and benefit from quicker checkouts, order histories and more!
            </div>

            <form id="createForm" method="post" accept-charset="UTF-8">

                {% macro errorList(errors) %}
                    {% if errors %}
                            {% for error in errors %}
                                <div class="errorMsg">{{ error }}</div>
                            {% endfor %}
                    {% endif %}
                {% endmacro %}
                {% from _self import errorList %}

                {% if account is defined %}
                    {{ errorList(account.getErrors('email')) }}
                {% endif %}

                {% if account is defined %}
                    {{ errorList(account.getErrors('password')) }}
                {% endif %}

                {{ getCsrfInput() }}
                <input type="hidden" name="action" value="users/saveUser">
                <input type="hidden" name="redirect" value="{{ siteUrl }}account/signup-sent">
                <div class="input">
                    <label>Email <span>*</span></label>
                    <input id="signupEmail" name="email" placeholder="Email" value="" data-parsley-type="email" data-parsley-required="true">
                </div>
                <div class="input">
                    <label>Confirm Email <span>*</span></label>
                    <input id="confirmEmail" placeholder="Confirm Email" value="" data-parsley-type="email" data-parsley-required="true" data-parsley-equalto="#signupEmail" data-parsley-equalto-message="Both emails must match">
                </div>
                <div class="input">
                    <label>Password <span>*</span></label>
                    <input name="password" id="password" type="password" placeholder="Password" value="" data-parsley-required="true" data-parsley-minlength="6" data-parsley-minlength-message="Password must be 6 characters or longer">
                </div>
                <div class="input">
                    <label>Confirm Password <span>*</span></label>
                    <input name="confirmPassword" id="confirmPassword" type="password" placeholder="Confirm Password" value="" data-parsley-required="true" data-parsley-equalto="#password" data-parsley-equalto-message="Both passwords must match">
                </div>
                <input type="hidden" name="fields[accountReceiveEmails]" value="">
                <div class="checkbox">
                    <input type="checkbox" name="fields[accountReceiveEmails][]" value="yes" id="emailOptin">
                    <label for="emailOptin"><span class="checkbox"><span></span></span>Yes, I would also like to receive offers, discounts and news for Cadex products by email.</label>
                </div>
                <footer>
                    <button>Create Account</button>
                </footer>
            </form>
        </div>

The login form posts to: users/login

The create an account form posts to: users/saveUser

This page has been working fine for the last year since the site launched and people have been creating accounts. However, sometime in the last 7 days something changed. We were alerted to the fact that users could not create accounts. When attempting to fill out the Create Account form, what happens now is an error gets returned for the Login form (try creating an account with any creds and see on the page url above). In the Craft logs, the following happens as well:

2018-04-24 17:36:31

Level   warning
Category    application
Message tried to log in unsuccessfully.

So it seems like suddenly the Create form is posting to login? There aren't any other errors we can see to explain this in the server logs or client-side. There have been no updates to any code, plugins or Craft during this time.

Oddly though, it looks like the correct data is getting posted. This is from the Craft logs:

$_POST=array (
'CRAFT_CSRF_TOKEN' => 'PGqJcG8ibNiBV8tNAeXsUl~2U2W7e9YHVo0YxaN6'
'action' => 'users/saveUser'
'redirect' => 'https://www.cadex.com/shop/account/signup-sent'
'email' => 'test1@coalescentdesign.com'
'password' => REDACTED
'confirmPassword' => 'password'
'fields' =>
array (
'accountReceiveEmails' => ''
)

Further, we have a staging version of this website where this issue does not happen.

Ideas anyone on what could be causing such unusual behaviour?

UPDATE

Is it possible Craft forces this post? We found this in `craft/app/services/HttpRequestService.php`:

$loginPath = trim(craft()->config->getLocalized('loginPath'), '/');
...
if ($this->_path == $loginPath)
{
$this->_actionSegments = array('users', 'login');
}

And our login path is set to: account/login'.

I am still puzzled though... why was this working - and still works in staging?

  • You input type is a button and no submit, do you usually do something with ajax/javascript in your form? Because there is a javascript error so it might not be executed correctly. There are several event listeners on that button -> that might be the issue. When you use external libraries via URL they might change or be offline. However: this causes it 'https://connect.facebook.net/en_US/fbevents.js';); <-- remove the ; – Robin Schambach Apr 25 '18 at 6:29
  • Thanks Robert. That JS error doesn't affect anything (we did try removing it just in case). As to the Submit button, same thing - adding type=submit doesn't make a difference either. – Mike Apr 25 '18 at 16:17
  • Really strange.. Have you tried to turn on dev mode - just for a second - and submit a request in order to receive more errors? – Robin Schambach Apr 25 '18 at 19:14
  • We have. Nothing more helpful. At this point we're looking into possibilities around the hosting environment or something else. Even more odd, that page in question will work if we move it to a different URL. Yeah, bizarre. – Mike Apr 25 '18 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.