-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Record login timestamp per user. Required for new user managament. #8681
Conversation
👍 |
@DeepDiver1975 IIRC you wanted to check this with Apache or another way of auth'ing? |
self::cleanupLoginTokens($_COOKIE['oc_username']); | ||
// get stored tokens | ||
$tokens = OC_Preferences::getKeys($_COOKIE['oc_username'], 'login_token'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where did that code goto? OC_User::loginWithCookie?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to lib/private/user/session.php line 188 (invoked by OC_User::loginWithCookie)
🚀 Test Passed. 🚀 |
💣 Test Failed. 💣 |
»Test Result (no failures)« |
Tested, code looks good 👍 |
Oh, i found one minor thing. The hour was given in 12h format but without am/pm indicator. Now its 24h format. So last commit changed just the case of one letter :) |
💣 Test Failed. 💣 |
Still no failures, why the script dos not return 0 is
tests are fine |
Can we use this opportunity to rename the functions to something saner than |
$lastLogin = $user->getLastLogin(); | ||
if($lastLogin === 0) { | ||
$output->writeln('User ' . $user->getUID() . | ||
' has never logged in, yet.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That statement is not entirely correct as this could also be triggered if an user has only not logged in since this feature has been added.
It may give the administrator a plausible misbelieve that the user has never logged in while this is not the case. Can we adjust this somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"has never logged in, yet." → "has never logged in (since availability of ownCloud 7.0.0)."
OK?
/** | ||
* updates the timestamp of the most recent login of this user | ||
* | ||
* @return null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this returns void
and not null
. Therefore the @return
statement can be dropped.
See http://www.phpdoc.org/docs/latest/for-users/phpdoc/tags/return.html:
It is RECOMMENDED when documenting to use this tag with every function and method. Exceptions to this recommendation are:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if no specific return is done (→ void) null will be returned, anyway, but I get the point and will drop it.
I haven't properly tested this yet. Please don't merge. |
💣 Test Failed. 💣 |
It would effect other files as well (e.g. core/lostpassword/controller.php, tests/autotest-clover-sqlite.xml), while I have nothing against changing the name I would prefer not to do it in this PR. |
… in class descripttion. Also fixes documentation of postLogin hook
Regarding the client: when launched the login timestamp will be updated, but as long as the client is running, even through days and suspending the laptop, the timestamp is not being updated. How is the client keeping the authentication? @DeepDiver1975 @danimo |
Desktop clients use the same session mechanisms as the browser does. |
The inspection completed: 6 new issues, 11 updated code elements |
🚀 Test Passed. 🚀 |
@DeepDiver1975 right, makes sense, i set back the session life time to default. In that case it probably make sense to check the timestamp on session regenerate too, and update it when the old one is > 24hrs (resp. session lifetime) ago. |
@LukasReschke when you look into your crystal ball, can you see when you do proper testing? |
My crystal ball says tomorrow 18:00 CET - at latest ;-) |
k, cool, thx |
🔮 said to me that I should 👍 this. |
Record login timestamp per user. Required for new user managament.
thank you @:crystal_ball: and @LukasReschke |
This PR cleans up the tryRememberLogin method first, moves the core part to the user session and also adds tests for it. This is necessary, because we need to record the timestamp as well, when a magic cookie (remember checkbox active) is used. The \OC\User\User object gets method to update and return the login timestamp. Updating the timestamp is triggered by postLogin and postRememberedLogin (new!) events. I tested it for login via web interface, remember cookie and desktop client.
There is also a command line tool to get the last login of a specific user. Example:
This PR is required for new user management in #7151.
Please test/review @LukasReschke @icewind1991 @DeepDiver1975