@@ -48,12 +48,13 @@ public static String getQueryToCreateSessionInfoTable(Start start) {
4848 return "CREATE TABLE IF NOT EXISTS " + sessionInfoTable + " ("
4949 + "session_handle VARCHAR(255) NOT NULL,"
5050 + "user_id VARCHAR(128) NOT NULL,"
51- + "refresh_token_hash_2 VARCHAR(128) NOT NULL,"
52- + "session_data TEXT,"
51+ + "refresh_token_hash_2 VARCHAR(128) NOT NULL,"
52+ + "session_data TEXT,"
5353 + "expires_at BIGINT NOT NULL,"
54- + "created_at_time BIGINT NOT NULL,"
55- + "jwt_user_payload TEXT,"
56- + "CONSTRAINT " + Utils .getConstraintName (schema , sessionInfoTable , null , "pkey" ) + " PRIMARY KEY(session_handle)" + " );" ;
54+ + "created_at_time BIGINT NOT NULL,"
55+ + "jwt_user_payload TEXT,"
56+ + "CONSTRAINT " + Utils .getConstraintName (schema , sessionInfoTable , null , "pkey" ) +
57+ " PRIMARY KEY(session_handle)" + " );" ;
5758 // @formatter:on
5859
5960 }
@@ -63,9 +64,10 @@ static String getQueryToCreateAccessTokenSigningKeysTable(Start start) {
6364 String accessTokenSigningKeysTable = Config .getConfig (start ).getAccessTokenSigningKeysTable ();
6465 // @formatter:off
6566 return "CREATE TABLE IF NOT EXISTS " + accessTokenSigningKeysTable + " ("
66- + "created_at_time BIGINT NOT NULL,"
67- + "value TEXT,"
68- + "CONSTRAINT " + Utils .getConstraintName (schema , accessTokenSigningKeysTable , null , "pkey" ) + " PRIMARY KEY(created_at_time)" + " );" ;
67+ + "created_at_time BIGINT NOT NULL,"
68+ + "value TEXT,"
69+ + "CONSTRAINT " + Utils .getConstraintName (schema , accessTokenSigningKeysTable , null , "pkey" ) +
70+ " PRIMARY KEY(created_at_time)" + " );" ;
6971 // @formatter:on
7072 }
7173
@@ -157,11 +159,15 @@ public static void deleteSessionsOfUser(Start start, String userId) throws SQLEx
157159 update (start , QUERY .toString (), pst -> pst .setString (1 , userId ));
158160 }
159161
160- public static String [] getAllSessionHandlesForUser (Start start , String userId )
162+ public static String [] getAllNonExpiredSessionHandlesForUser (Start start , String userId )
161163 throws SQLException , StorageQueryException {
162- String QUERY = "SELECT session_handle FROM " + getConfig (start ).getSessionInfoTable () + " WHERE user_id = ?" ;
164+ String QUERY = "SELECT session_handle FROM " + getConfig (start ).getSessionInfoTable ()
165+ + " WHERE user_id = ? AND expires_at >= ?" ;
163166
164- return execute (start , QUERY , pst -> pst .setString (1 , userId ), result -> {
167+ return execute (start , QUERY , pst -> {
168+ pst .setString (1 , userId );
169+ pst .setLong (2 , currentTimeMillis ());
170+ }, result -> {
165171 List <String > temp = new ArrayList <>();
166172 while (result .next ()) {
167173 temp .add (result .getString ("session_handle" ));
0 commit comments