SMF icon indicating copy to clipboard operation
SMF copied to clipboard

Login failing on second attempt

Open jdarwood007 opened this issue 13 years ago • 9 comments

I am getting a lot of login failures on my second attempt to login.

After some digging around, I am finding SMF when it detects a failed login is destroying the session, which is causing the server to send a new cookie.

To reproduce:

  1. Open Chrome developer tools (or equivalent)
  2. Navigate to your SMF login page and note the cookie in the request headers, also note the response headers do not contain any.
  3. Do a failed login (such as a bad password)
  4. Note the request headers have the original cookie, note that response headers are now sending back a new cookie and SMF cookie.

This causes logins to fail because the session checks now fail. Somewhere along the line we are doing this on failed logins. I haven't been able to track that down yet, but need to open this to make sure we look into fixing that yet.

jdarwood007 avatar Aug 09 '13 03:08 jdarwood007

More tracking, its because of setLoginCookie

It appears to destroy the session and recreate the new one. While it attempts to save the $_SESSION data, I don't think this is happening.

jdarwood007 avatar Aug 09 '13 03:08 jdarwood007

As far as I remember, this has always been the behaviour. The only new thing in 2.1 is the token (that is used to hash the pair username/password),

/me guesses the problem is the token is not recreated soon enough or is recreated twice or so.

emanuele45 avatar Aug 09 '13 06:08 emanuele45

The error is not about a token mismatch but about session check failing. The problem seems to be because the cookie has changed because a new session id was set.

jdarwood007 avatar Aug 09 '13 14:08 jdarwood007

Okay, I tried to really replicate this and this is how I can replicate it:

  • action=login
  • insert wrong password
  • insert wrong password (a second time)
  • insert correct password => reminder instead of login

Now, if I disable javascript the login happens correctly. That means the problem is likely in the hashing. Since in 2.1 the hashing is using a token to make the hashed code POST'ed unique I really feel this is a token "mismatch" (but not in the sense that validateToken fails, because in that case validateToken is not involved at all).

emanuele45 avatar Aug 09 '13 20:08 emanuele45

Hmm, I can easily reproduce it on the second failed login attempt. It always gives me a session error and when I check it out (dumping out data), I see my php session id has changed.

I wonder why we even recreate a new session and cookie. Is this even necessary?

jdarwood007 avatar Aug 11 '13 17:08 jdarwood007

I think this is the same or a similar issue to #447

ghost avatar Aug 12 '13 08:08 ghost

This was mostly caused by not doing the proper token verification. Login does those. This seems to be related to some session related issue. If I disable tokens on the login screen this still happens. Which leads me to believe its apart of the session issues still.

Its nice whoever setup login tokens made it fairly easy to disable, no template edits required.

jdarwood007 avatar Aug 13 '13 04:08 jdarwood007

I think this one has been fixed somewhere along the way?

AngelinaBelle avatar Jun 27 '14 20:06 AngelinaBelle

Most likely.

live627 avatar Jun 28 '14 00:06 live627