Stop polling for torrents if the user logged out

This commit is contained in:
Grégoire Delattre 2017-05-21 14:52:14 +02:00
parent 7ccfce9136
commit 316a850eec

View File

@ -89,7 +89,7 @@ const loginCheck = function(nextState, replace, next, f) {
// Let's check if the user has a token, if he does let's assume he's logged
// in. If that's not the case he will be logged out on the fisrt query
if (token !== "") {
if (token && token !== "") {
store.dispatch({
type: 'USER_SET_TOKEN',
payload: {
@ -98,7 +98,7 @@ const loginCheck = function(nextState, replace, next, f) {
});
}
if (!isLogged && token === "") {
if (!isLogged && (!token || token === "")) {
replace('/users/login');
} else {
f();
@ -126,6 +126,11 @@ const routes = {
{
path: '/users/logout',
onEnter: function(nextState, replace, next) {
// Stop polling
if (pollingTorrentsId !== null) {
clearInterval(pollingTorrentsId);
pollingTorrentsId = null;
}
store.dispatch(actionCreators.userLogout());
replace('/users/login');
next();