Skip to content

Record login timestamp per user. Required for new user managament. - #8681

Merged
LukasReschke merged 13 commits into
masterfrom
logintimestamp
May 28, 2014
Merged

LukasReschke merged 13 commits into
masterfrom
logintimestamp

Conversation

@blizzz

@blizzz blizzz commented May 23, 2014

Copy link
Copy Markdown
Contributor

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:

$ ./occ user:lastseen master
master`s last login: 23.05.2014 08:48

This PR is required for new user management in #7151.

Please test/review @LukasReschke @icewind1991 @DeepDiver1975

@karlitschek

Copy link
Copy Markdown
Contributor

👍

@blizzz

blizzz commented May 23, 2014

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 IIRC you wanted to check this with Apache or another way of auth'ing?

Comment thread lib/base.php

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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)

@ghost

ghost commented May 23, 2014

Copy link
Copy Markdown

@ghost

ghost commented May 23, 2014

Copy link
Copy Markdown

@blizzz

blizzz commented May 23, 2014

Copy link
Copy Markdown
Contributor Author

»Test Result (no failures)«

@blizzz blizzz added this to the ownCloud 7 milestone May 23, 2014
@icewind1991

Copy link
Copy Markdown
Contributor

Tested, code looks good 👍

@blizzz

blizzz commented May 23, 2014

Copy link
Copy Markdown
Contributor Author

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 :)

@ghost

ghost commented May 23, 2014

Copy link
Copy Markdown

@blizzz

blizzz commented May 23, 2014

Copy link
Copy Markdown
Contributor Author

Still no failures, why the script dos not return 0 is

16:22:43 npm ERR! Failed to parse json
16:22:43 npm ERR! Unexpected end of input
16:22:43 npm ERR! File: /var/lib/jenkins/.npm/karma-phantomjs-launcher/0.1.4/package/package.json

tests are fine

@LukasReschke

Copy link
Copy Markdown
Contributor

Can we use this opportunity to rename the functions to something saner than magic cookie? - It's absolutely unusual named and hard to understand. (Remember me, Remember, whatever..)

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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?

Comment thread lib/private/user/user.php Outdated

Copy link
Copy Markdown
Contributor

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:

  • constructors, the @return tag MAY be omitted here, in which case @return self is implied.
  • functions and methods without a return value, the @return tag MAY be omitted here, in which case @return void is implied.

Copy link
Copy Markdown
Contributor Author

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.

@LukasReschke

Copy link
Copy Markdown
Contributor

I haven't properly tested this yet. Please don't merge.

@ghost

ghost commented May 24, 2014

Copy link
Copy Markdown

@blizzz

blizzz commented May 26, 2014

Copy link
Copy Markdown
Contributor Author

Can we use this opportunity to rename the functions to something saner than magic cookie? - It's absolutely unusual named and hard to understand. (Remember me, Remember, whatever..)

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.

@blizzz

blizzz commented May 26, 2014

Copy link
Copy Markdown
Contributor Author

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

@DeepDiver1975

Copy link
Copy Markdown
Contributor

How is the client keeping the authentication? @DeepDiver1975 @danimo

Desktop clients use the same session mechanisms as the browser does.
But the mobile apps (as long as not authenticating via shibboleth) still use basic auth, which would trigger a login on every request

@scrutinizer-notifier

Copy link
Copy Markdown

The inspection completed: 6 new issues, 11 updated code elements

@ghost

ghost commented May 26, 2014

Copy link
Copy Markdown

@blizzz

blizzz commented May 26, 2014

Copy link
Copy Markdown
Contributor Author

@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.

@blizzz

blizzz commented May 28, 2014

Copy link
Copy Markdown
Contributor Author

@LukasReschke when you look into your crystal ball, can you see when you do proper testing?

@LukasReschke

Copy link
Copy Markdown
Contributor

@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 ;-)

@blizzz

blizzz commented May 28, 2014

Copy link
Copy Markdown
Contributor Author

k, cool, thx

@LukasReschke

Copy link
Copy Markdown
Contributor

🔮 said to me that I should 👍 this.

LukasReschke added a commit that referenced this pull request May 28, 2014
Record login timestamp per user. Required for new user managament.
@LukasReschke
LukasReschke merged commit ce9d5df into master May 28, 2014
@LukasReschke
LukasReschke deleted the logintimestamp branch May 28, 2014 17:06
@blizzz

blizzz commented May 28, 2014

Copy link
Copy Markdown
Contributor Author

thank you @:crystal_ball: and @LukasReschke

blizzz added a commit that referenced this pull request Jun 2, 2014
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants