Mercurial > gemma
annotate client/src/lib/session.js @ 163:30c212a6f580
fix: Bugfix for session evaluation
Refactoring the session introduced bug.
Expires is stored as string and not time millis.
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 05 Jul 2018 18:15:04 +0200 |
parents | 9908260d1e6a |
children | 4bf2173748f3 |
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(); |
163
30c212a6f580
fix: Bugfix for session evaluation
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
4 const sessionEnd = |
30c212a6f580
fix: Bugfix for session evaluation
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
5 typeof expiresFromPastSession === "string" |
30c212a6f580
fix: Bugfix for session evaluation
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
6 ? expiresFromPastSession * 1000 |
30c212a6f580
fix: Bugfix for session evaluation
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
7 : expiresFromPastSession; |
162
9908260d1e6a
Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
8 const stillActive = now < sessionEnd; |
9908260d1e6a
Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
9 return stillActive; |
9908260d1e6a
Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
10 } |
9908260d1e6a
Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
11 |
9908260d1e6a
Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
12 export { sessionStillActive }; |