Skip to content

Commit a51215d

Browse files
committed
refactor function name and a comment
1 parent 08c8fde commit a51215d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

dashboard/src/actions/authActions.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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) => {
6567
export const sessionLogout = () => async (dispatch, getState) => {
6668
const keycloak = getState().apiEndpoint.keycloak;
6769
keycloak.logout();
68-
dispatch(localLogout());
70+
dispatch(clearCachedSession());
6971
};

dashboard/src/actions/toastActions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as TYPES from "./types";
22

33
import { uid } from "utils/helper";
4-
import { localLogout } from "./authActions";
4+
import { clearCachedSession } from "./authActions";
55

66
export const showSessionExpired = () => async (dispatch) => {
77
const toast = {
@@ -10,7 +10,7 @@ export const showSessionExpired = () => async (dispatch) => {
1010
message: "Please login to continue",
1111
};
1212
dispatch(showToast(toast.variant, toast.title, toast.message));
13-
dispatch(localLogout());
13+
dispatch(clearCachedSession());
1414
};
1515

1616
export const showFailureToast = () => async (dispatch) => {

0 commit comments

Comments
 (0)