Skip to content

Commit be09cf4

Browse files
#4140: Changed the approach to reload notifications if auth token is changed.
1 parent 2a85acd commit be09cf4

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/shared/components/Header/index.jsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import _ from 'lodash';
22
import React, { useState, useEffect } from 'react';
33
import PT from 'prop-types';
44
import { config } from 'topcoder-react-utils';
5-
import { isTokenExpired } from 'tc-accounts';
6-
import { goToLogin } from 'utils/tc';
75
import Logo from 'assets/images/tc-logo.svg';
86

97
let TopNavRef;
@@ -52,17 +50,18 @@ const Header = ({
5250

5351
useEffect(() => {
5452
setPath(window.location.pathname);
53+
}, []);
5554

56-
if (auth.authenticating) return;
57-
58-
// Check auth token, go to login page if expired
59-
if (auth.tokenV3 && isTokenExpired(auth.tokenV3)) {
60-
goToLogin('community-app-main');
61-
return;
62-
}
55+
/*
56+
* Reload notificaitons if token was changed
57+
* This prevent to use expired token in API call
58+
*/
59+
if (auth) {
60+
useEffect(() => {
61+
loadNotifications(auth.tokenV3);
62+
}, [auth.tokenV3]);
63+
}
6364

64-
loadNotifications(auth.tokenV3);
65-
}, []);
6665
if (TopNavRef) {
6766
return (
6867
<div>

src/shared/containers/TopcoderHeader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ function mapStateToProps(state) {
4848
notifications: (state.notifications
4949
&& state.notifications.items
5050
&& [...state.notifications.items]) || [],
51-
auth: state.auth,
51+
auth: {
52+
...state.auth,
53+
},
5254
};
5355
}
5456

0 commit comments

Comments
 (0)