File tree 2 files changed +13
-12
lines changed
2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ import _ from 'lodash';
2
2
import React , { useState , useEffect } from 'react' ;
3
3
import PT from 'prop-types' ;
4
4
import { config } from 'topcoder-react-utils' ;
5
- import { isTokenExpired } from 'tc-accounts' ;
6
- import { goToLogin } from 'utils/tc' ;
7
5
import Logo from 'assets/images/tc-logo.svg' ;
8
6
9
7
let TopNavRef ;
@@ -52,17 +50,18 @@ const Header = ({
52
50
53
51
useEffect ( ( ) => {
54
52
setPath ( window . location . pathname ) ;
53
+ } , [ ] ) ;
55
54
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
+ }
63
64
64
- loadNotifications ( auth . tokenV3 ) ;
65
- } , [ ] ) ;
66
65
if ( TopNavRef ) {
67
66
return (
68
67
< div >
Original file line number Diff line number Diff line change @@ -48,7 +48,9 @@ function mapStateToProps(state) {
48
48
notifications : ( state . notifications
49
49
&& state . notifications . items
50
50
&& [ ...state . notifications . items ] ) || [ ] ,
51
- auth : state . auth ,
51
+ auth : {
52
+ ...state . auth ,
53
+ } ,
52
54
} ;
53
55
}
54
56
You can’t perform that action at this time.
0 commit comments