diff options
author | Anton Tananaev <anton@traccar.org> | 2023-11-26 08:18:32 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-11-26 08:18:32 -0800 |
commit | fc8678b22929026e6c62284add8ff1cbca247f20 (patch) | |
tree | cb4ef554b1074585fc31bc531e7c884dce433ca0 /src/main/java/org/traccar/api/resource/SessionResource.java | |
parent | acdc451e3e2ab94f548f078c4bd49985b3c2f01d (diff) | |
download | trackermap-server-fc8678b22929026e6c62284add8ff1cbca247f20.tar.gz trackermap-server-fc8678b22929026e6c62284add8ff1cbca247f20.tar.bz2 trackermap-server-fc8678b22929026e6c62284add8ff1cbca247f20.zip |
Store session expiration
Diffstat (limited to 'src/main/java/org/traccar/api/resource/SessionResource.java')
-rw-r--r-- | src/main/java/org/traccar/api/resource/SessionResource.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/api/resource/SessionResource.java b/src/main/java/org/traccar/api/resource/SessionResource.java index 3e80e0020..0435f4f92 100644 --- a/src/main/java/org/traccar/api/resource/SessionResource.java +++ b/src/main/java/org/traccar/api/resource/SessionResource.java @@ -17,6 +17,7 @@ package org.traccar.api.resource; import org.traccar.api.BaseResource; import org.traccar.api.security.CodeRequiredException; +import org.traccar.api.security.LoginResult; import org.traccar.api.security.LoginService; import org.traccar.api.signature.TokenManager; import org.traccar.database.OpenIdProvider; @@ -61,6 +62,7 @@ import java.net.URI; public class SessionResource extends BaseResource { public static final String USER_ID_KEY = "userId"; + public static final String EXPIRATION_KEY = "expiration"; public static final String USER_COOKIE_KEY = "user"; public static final String PASS_COOKIE_KEY = "password"; @@ -82,9 +84,11 @@ public class SessionResource extends BaseResource { public User get(@QueryParam("token") String token) throws StorageException, IOException, GeneralSecurityException { if (token != null) { - User user = loginService.login(token).getUser(); + LoginResult loginResult = loginService.login(token); + User user = loginResult.getUser(); if (user != null) { request.getSession().setAttribute(USER_ID_KEY, user.getId()); + request.getSession().setAttribute(EXPIRATION_KEY, loginResult.getExpiration()); LogAction.login(user.getId(), WebHelper.retrieveRemoteAddress(request)); return user; } |