User login timeout? how do automatically log user out after 30 minutes, for example?


#1

an internet search gave me two possibilities, but both gave me pause:

  1. https://atmospherejs.com/mrt/session-timeout
    (this has no information , no git repo, no installation or configuration instructions, so it may not even do what I want)

  2. https://github.com/recursivefaults/meteor-session-timeout
    (this seems to be what I want, but it has the opposite issue as #1, it doesn’t seem to be listed in atmosphere, so I dont know how to install it)

any suggestions here?

thank you


#2

You can use the concepts and code from the second one to create your own functioning code.

You might even want to share it as a package :smile:


#3

I’m confused… #2 says in it’s github repo that it is a “meteorite package”… so isn’t it already a package that I can add to my meteor project? I’m new to this world :smile:


#4

if it is not available on atmosphere, you can just clone the repo in the packages folder (create it when it is not your projects root folder) and add it from there. Add a name to the packages.js of the package:

Package.describe({
    "summary": "Simple configurable session timeout",
    "name": "yourinitials:sessiontimeout"
});

and install it with meteor add yourinitials:sessiontimeout.


#5

So does that place it into atmosphere for others to use? or just for my local application?


#6

just for your local application.


#7

ok, I’ll try that, thanks for the help… this functionality really should be built into the core!


#8

Have you seen this one:
https://atmospherejs.com/zuuk/stale-session


#9

yes, thanks… I did come across that and have been using it with some success.


#10

It seems like this now is possible by running the following code:

Accounts.config({
    loginExpirationInDays: (1 / 24 / 60) * 30
});

As far as I can see, the setting loginExpirationInDays is only used in https://github.com/meteor/meteor/blob/8005532f4ba847d3e8bb4c1100d09bf53136ff0a/packages/accounts-base/accounts_common.js#L217 which allows the usage of comma values.

EDIT: The lowest value I got working was 0.05, which is 1 hour and 12 minutes … It doesn’t kick out the user but only prevents a re-login (f.e. by reloading the page).

Please vote for https://github.com/meteor/meteor-feature-requests/issues/119 for smaller values.

EDIT2: I guess loginExpirationInDays was thought for something different. Please read the PR before using it.


#11

If you (like me) are interested in a client-side timeout (or what to know how it works): https://atmospherejs.com/simonsimcity/client-session-timeout

Towards the end of this post I compared my extension against others like https://atmospherejs.com/zuuk/stale-session which have a server-side timeout: https://github.com/meteor/meteor-feature-requests/issues/119#issuecomment-364748281

Choose the one fitting best to your use-case.