logout is working If I didn't refresh the browser.After refeshing the browser logout not working. Is there any solution for it?
Below is the saga code that I had written for the logout action
//...function
export function* logout() {
yield put({ type: 'SENDING_REQUEST', sending: true });
try {
let response = yield call(auth.logout);
yield put({ type: 'SENDING_REQUEST', sending: false });
} catch (error) {
yield put({ type: 'REQUEST_ERROR', error: error.message });
}
}
export function* logoutFlow() {
while (true) {
yield take('LOGOUT');
yield put({ type: 'SET_AUTH', newAuthState: false });
yield call(logout);
forwardTo('/login');
}
}
export function* logoutRoot() {
yield fork(logoutFlow);
}
export function* watcherRoot() {
const watcher2 = yield fork(logoutRoot);
}
export default [
mainRoot,
watcherRoot,
];
Hello @prudhvisays, what is auth.logout doing ? Is it possible that you actually are setting the authstate to false on logout, but some 'autologin' is happening (on reload) because of the fact that localstorage is checked for some data (maybe a token ?) when the store is initiated - which happens on reload ?
code is correct and working fine now.
Problem is with global saga. saga should be in app level(global) to work. Earlier injected auth saga in component level thats why it didn't work after browser refresh
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
code is correct and working fine now.
Problem is with global saga. saga should be in app level(global) to work. Earlier injected auth saga in component level thats why it didn't work after browser refresh