The option to display the user's last login/access doesn't seem to be setting the message through drupal_set_message for a successful login.

CommentFileSizeAuthor
#1 login_security_492600_1.patch1.39 KBilo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ilo’s picture

Assigned: Unassigned » ilo
Status: Active » Needs review
FileSize
1.39 KB

mm...

Currently the notification of the last access and login is done in the "login" op of the hook_user, what IMHO is not correct. The last access could be done in the the 'login' op, as account is loaded with this value untouched in the $account param. The problem is for the last login timestamp. The account is loaded, but not in the $user variable, therefore the values are not populated to the 'login' op.

This patch will update the "last login" variable everytime a user is loaded. I don't like it but it works. For the login workflow, only one account is loaded, and it's the logged in account. The last access timestamp is fixed also.

deekayen’s picture

Status: Needs review » Needs work

I actually made that same patch on my own. It fails the additional tests I just committed. The problem shows on a user's first login. hook_user is firing the login op first and those elements of the object are set, but the access and login are already set by then. That means the last login time is the same instance of the current login.

deekayen’s picture

Perhaps the new user_load I added to the validate could be used to temporarily store the access and login time? Then unset it from the session after the drupal_set_message is executed.

ilo’s picture

I'll commit this and the other minor issues for now, and we can review the login process more deeply later. Do you think we can consider the "first login issue" as normal situation for now?.

Do I patch and commit?

deekayen’s picture

I don't see it as a minor issue. It breaks the tests because there is a message on the first login and shouldn't be one at all. The subsequent logins also show the current login's instance timestamp. I just meant I discovered the problem because the first login shouldn't have had a message in the first place. The previous login tests I committed don't assertPattern for a reasonable date string which is why the rest of the tests don't fail.

deekayen’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • deekayen committed de69dc7 on 6.x-1.x, 8.x-1.x
    tests for #492600
    
    
  • deekayen committed 987b656 on 6.x-1.x, 8.x-1.x
    #492600 - Last login didn't display. Found a solution that passes tests...