@@ -36,7 +36,9 @@ export const authCookies = () => async (dispatch, getState) => {
3636 await waitForEndpoints ( getState ) ;
3737 const keycloak = getState ( ) . apiEndpoint . keycloak ;
3838 if ( keycloak . authenticated ) {
39- // Set the cookie expiry to milliseconds since the UNIX Epoch
39+ // Set the isLoggedIn cookie with an expiry of OIDC refresh token.
40+ // We have to convert the UNIX epoch seconds returned by the refresh token
41+ // expiry to milliseconds before we can use it for creating a Date object.
4042 Cookies . set ( "isLoggedIn" , true , {
4143 expires : new Date ( keycloak . refreshTokenParsed . exp * 1000 ) ,
4244 } ) ;
@@ -53,7 +55,7 @@ export const movePage = (toPage, navigate) => async (dispatch) => {
5355 navigate ( toPage ) ;
5456} ;
5557
56- export const localLogout = ( ) => async ( dispatch , getState ) => {
58+ export const clearCachedSession = ( ) => async ( dispatch , getState ) => {
5759 dispatch ( { type : TYPES . LOADING } ) ;
5860 Cookies . remove ( "isLoggedIn" ) ;
5961 dispatch ( { type : TYPES . COMPLETED } ) ;
@@ -65,5 +67,5 @@ export const localLogout = () => async (dispatch, getState) => {
6567export const sessionLogout = ( ) => async ( dispatch , getState ) => {
6668 const keycloak = getState ( ) . apiEndpoint . keycloak ;
6769 keycloak . logout ( ) ;
68- dispatch ( localLogout ( ) ) ;
70+ dispatch ( clearCachedSession ( ) ) ;
6971} ;
0 commit comments