annotate client/src/lib/session.js @ 172:a422471db08a

Automate running DB-tests with an extra database run_tests.sh allows to run database tests easily without affecting other existing databases and on a clean basis. Because roles are cluster-wide, they cannot be easily droped and recreated without affecting other databases. Thus, moved their creation to roles.sql and in passing removed unnecessary role 'gemma'.
author Tom Gottfried <tom@intevation.de>
date Thu, 12 Jul 2018 16:30:01 +0200
parents 4bf2173748f3
children 27502291e564
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
162
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
1 function sessionStillActive(expiresFromPastSession) {
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
2 if (!expiresFromPastSession) return false;
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
3 const now = Date.now();
165
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 163
diff changeset
4 const stillActive = now < expiresFromPastSession;
162
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
5 return stillActive;
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
6 }
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
7
165
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 163
diff changeset
8 function toMillisFromString(timestring) {
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 163
diff changeset
9 return timestring * 1000;
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 163
diff changeset
10 }
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 163
diff changeset
11
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 163
diff changeset
12 export { sessionStillActive, toMillisFromString };