diff --git a/modules/core/src/com/haulmont/cuba/restapi/ServerTokenStoreImpl.java b/modules/core/src/com/haulmont/cuba/restapi/ServerTokenStoreImpl.java index e4602f52eb..0063bccd2a 100644 --- a/modules/core/src/com/haulmont/cuba/restapi/ServerTokenStoreImpl.java +++ b/modules/core/src/com/haulmont/cuba/restapi/ServerTokenStoreImpl.java @@ -31,8 +31,10 @@ import com.haulmont.cuba.core.global.TimeSource; import com.haulmont.cuba.core.global.View; import com.haulmont.cuba.core.sys.AppContext; import com.haulmont.cuba.core.sys.SecurityContext; +import com.haulmont.cuba.security.app.UserSessionLog; import com.haulmont.cuba.security.app.UserSessionsAPI; import com.haulmont.cuba.security.auth.AuthenticationManager; +import com.haulmont.cuba.security.entity.SessionAction; import com.haulmont.cuba.security.global.NoUserSessionException; import com.haulmont.cuba.security.global.UserSession; import org.apache.commons.lang.LocaleUtils; @@ -59,6 +61,9 @@ public class ServerTokenStoreImpl implements ServerTokenStore { @Inject protected AuthenticationManager authenticationManager; + @Inject + protected UserSessionLog userSessionLog; + @Inject protected UserSessionsAPI userSessions; @@ -527,8 +532,6 @@ public class ServerTokenStoreImpl implements ServerTokenStore { try { refreshTokenValueToRefreshTokenStore.put(refreshToken.getTokenValue(), refreshToken.getTokenBytes()); refreshTokenValueToAuthenticationStore.put(refreshToken.getTokenValue(), refreshToken.getAuthenticationBytes()); - - } finally { lock.writeLock().unlock(); } @@ -598,6 +601,8 @@ public class ServerTokenStoreImpl implements ServerTokenStore { AppContext.setSecurityContext(new SecurityContext(session)); try { authenticationManager.logout(); + + userSessionLog.updateSessionLogRecord(session, SessionAction.LOGOUT); } finally { AppContext.setSecurityContext(null); } diff --git a/modules/core/src/com/haulmont/cuba/security/auth/AuthenticationServiceBean.java b/modules/core/src/com/haulmont/cuba/security/auth/AuthenticationServiceBean.java index 34055a0725..f8e5a66795 100644 --- a/modules/core/src/com/haulmont/cuba/security/auth/AuthenticationServiceBean.java +++ b/modules/core/src/com/haulmont/cuba/security/auth/AuthenticationServiceBean.java @@ -141,8 +141,6 @@ public class AuthenticationServiceBean implements AuthenticationService { throw new RuntimeException("Logout of system session from client is not permitted"); } - userSessionLog.updateSessionLogRecord(session, SessionAction.LOGOUT); - authenticationManager.logout(); userSessionLog.updateSessionLogRecord(session, SessionAction.LOGOUT);