Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
document.addEventListener('keydown', this.onKeyDown)
const { game, dispatch } = this.props
if (game.status === 'idle') {
dispatch(replace('/'))
}
// 这里不考虑这种情况:玩家在游戏过程中手动在地址栏中输入了 /gameover
}
componentWillMount() {
const { dispatch } = this.props;
const { query } = this.props.location;
// eslint-disable-next-line object-curly-newline, camelcase
const { refresh_token, access_token, expires_at, next = '/' } = query;
const tokens = {
refresh_token,
access_token,
expires_at: expires_at ? parseFloat(expires_at, 10) : Infinity, // eslint-disable-line camelcase
};
dispatch(storeTokens(tokens));
dispatch(getAuth(tokens));
dispatch(replace(next));
}
return (dispatch) => {
let url = redirectAfterLogin ? `/login?next=${redirectAfterLogin}` : '/login';
if (withReplace) {
dispatch(replace(url));
} else {
dispatch(push(url));
}
};
}