aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api/resource
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/api/resource')
-rw-r--r--src/main/java/org/traccar/api/resource/SessionResource.java6
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;
}