CodeIgniter-Aauth icon indicating copy to clipboard operation
CodeIgniter-Aauth copied to clipboard

last_login currently useless

Open paulcanning opened this issue 7 years ago • 9 comments

The way the last_login timestamp it updated makes it practically useless in its current state.

The timestamp is updated after a successful login, every time. So you can never actually see the "last/previous" time you logged in, as the single last_login timestamp is always updated, wiping away the old timestamp.

Really, you need two columns; login and last_login. login gets updated with the current time after you log in, and last_login is updated with the timestamp from login just before it gets updated.

paulcanning avatar Jan 26 '17 11:01 paulcanning

Nice idea, I'll add this to v3

REJack avatar Jan 26 '17 15:01 REJack

I'm going to fix it in my v2, so I can try and put together a PR for it once I have it working.

paulcanning avatar Jan 26 '17 16:01 paulcanning

I must say I disagree with this. "Last Login" should mean the timestamp of the latest login, which if you are logged in would be the time you logged in. What would be the purpose of having the timestamp of the next to last login, other than pure curiosity?

Last login is a term used all over, for example by admins looking at user registry to see when people last logged in.

perenstrom avatar Feb 14 '17 08:02 perenstrom

If you read the post, you'd see it is CURRENTLY useless. As in, it is CURRENTLY broken.

paulcanning avatar Feb 14 '17 12:02 paulcanning

No need to be snarky. I did read your post, did you read mine?

As I said, "last login" should be the lates login you have made, not the one previous to that.

perenstrom avatar Apr 13 '17 06:04 perenstrom

That makes zero sense.

Think about it. For peace of mind and maybe security reasons, I want to see when my account was LAST logged in.

As of right now, in the code base, whenever a login is made, the last_login timestamp is updated, meaning you can never know when a previous successful login was made (imagine someone got your password and logged in as you).

If you store the previous successful login, a user can easily recognise if it was them that logged in, rather then someone claiming to me them.

Do you get it now?

paulcanning avatar Apr 13 '17 08:04 paulcanning

@paulcanning last_login as you see it is good, however it should also have the IP address as well as the user_agent if you want to investigate the matter further.

salain avatar Apr 13 '17 08:04 salain

@paulcanning It does make sense. If I log on to my server, let's say Exchange server, as an admin and look at my user table. In the Last_logon field I would expect to see the latest time the user in question logged on. This is the way all systems I've come in contact with handle something called "last_logon".

Now I DO see your point about as a user being interested in when my previous login was (even though I think it's an edge case scenario). I don't think the feature is requested enough by users to make it a standard part of an authentication library. I would probably create my own logging table which would log all log in (and log in attempts) to a user and make that available to the user.

perenstrom avatar Apr 13 '17 10:04 perenstrom

Hey together, we have already a login_attempts table with any login attempt, we could add a successfully & user_id field in the database and if the config option remove_successful_attempts is false we can update the fields instead of remove the attempt 😄.

@salain The IP address is already in the users & login_attempts table but the user_agent is a great idea.

REJack avatar Apr 14 '17 01:04 REJack