Skip to content

Commit fdd6110

Browse files
Merge branch 'development' into Ajay-fixed-search-bar-in-communityportal
2 parents d26c739 + 172e09c commit fdd6110

139 files changed

Lines changed: 8635 additions & 5425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config-overrides.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line import/no-extraneous-dependencies
12
const webpack = require('webpack');
23

34
module.exports = function override(config) {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions/__tests__/authActions.js.test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
setCurrentUser, // Import setCurrentUser action
1414
setHeaderData, // Import setHeaderData action
1515
} from '../authActions'; // Import actions from authActions
16-
import { SET_CURRENT_USER, SET_HEADER_DATA } from '../../constants/auth'; // Import constants
16+
import { SET_CURRENT_USER, SET_HEADER_DATA, STOP_FORCE_LOGOUT } from '../../constants/auth'; // Import constants
1717

1818

1919
const middlewares = [thunk]; // Define middlewares
@@ -35,7 +35,10 @@ describe('authActions', () => {
3535
httpService.post.mockResolvedValue({ data: { token } }); // Mock the httpService post method
3636
jwtDecode.mockReturnValue(decodedToken); // Mock the jwtDecode function
3737

38-
const expectedActions = [{ type: SET_CURRENT_USER, payload: decodedToken }]; // Define expected actions
38+
const expectedActions = [
39+
{ type: STOP_FORCE_LOGOUT }, // Ensure any existing timers are cleared
40+
{ type: SET_CURRENT_USER, payload: decodedToken },
41+
]; // Define expected actions
3942

4043
await store.dispatch(loginUser(credentials)); // Dispatch the loginUser action
4144
expect(store.getActions()).toEqual(expectedActions); // Assert the actions
@@ -68,7 +71,10 @@ describe('authActions', () => {
6871

6972
it('creates SET_CURRENT_USER with null when logoutUser is called', () => {
7073
const store = mockStore({}); // Create a mock store
71-
const expectedActions = [{ type: SET_CURRENT_USER, payload: null }]; // Define expected actions
74+
const expectedActions = [
75+
{ type: STOP_FORCE_LOGOUT }, // Clear any active force-logout timer
76+
{ type: SET_CURRENT_USER, payload: null },
77+
]; // Define expected actions
7278

7379
store.dispatch(logoutUser()); // Dispatch the logoutUser action
7480
expect(store.getActions()).toEqual(expectedActions); // Assert the actions

src/actions/authActions.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
SET_CURRENT_USER,
99
SET_HEADER_DATA,
1010
START_FORCE_LOGOUT,
11+
STOP_FORCE_LOGOUT,
1112
} from '../constants/auth';
1213

1314
const { tokenKey } = config;
@@ -22,6 +23,21 @@ export const setHeaderData = data => ({
2223
payload: data,
2324
});
2425

26+
/**
27+
* Stops any active force logout timer and clears related state
28+
*/
29+
export const stopForceLogout = () => (dispatch, getState) => {
30+
const { auth } = getState();
31+
if (auth?.timerId) {
32+
try {
33+
clearTimeout(auth.timerId);
34+
} catch (e) {
35+
// Timer already cleared or invalid
36+
}
37+
}
38+
dispatch({ type: STOP_FORCE_LOGOUT });
39+
};
40+
2541
export const loginUser = credentials => dispatch => {
2642
return httpService
2743
.post(ENDPOINTS.LOGIN, credentials)
@@ -33,6 +49,8 @@ export const loginUser = credentials => dispatch => {
3349
localStorage.setItem(tokenKey, res.data.token);
3450
httpService.setjwt(res.data.token);
3551
const decoded = jwtDecode(res.data.token);
52+
// Ensure any existing timers from a previous session are cleared
53+
dispatch(stopForceLogout());
3654
dispatch(setCurrentUser(decoded));
3755
return { success: true };
3856
})
@@ -98,6 +116,8 @@ export const getHeaderData = userId => {
98116
};
99117

100118
export const logoutUser = () => dispatch => {
119+
// Clear any active force-logout timer before logging out
120+
dispatch(stopForceLogout());
101121
localStorage.removeItem(tokenKey);
102122
httpService.setjwt(false);
103123
dispatch(setCurrentUser(null));
@@ -134,6 +154,9 @@ export const startForceLogout = (delayMs = 20000) => (dispatch, getState) => {
134154
// eslint-disable-next-line no-console
135155
console.error('Error acknowledging permissions during force logout:', error);
136156
} finally {
157+
// Set flag to indicate user was force logged out due to permission changes
158+
// This helps distinguish "force logged out" vs "first login after permission change"
159+
sessionStorage.setItem('wasForceLoggedOut', 'true');
137160
dispatch(logoutUser());
138161
}
139162
}, delayMs);

0 commit comments

Comments
 (0)