Logout via AJAX
This commit is contained in:
@ -1,3 +1,17 @@
|
||||
import { call, put } from 'redux-saga/effects';
|
||||
import { LOGOUT_FAILURE, LOGOUT_SUCCESS } from '../actions/logout';
|
||||
|
||||
export function* logoutSaga() {
|
||||
window.location = '/logout';
|
||||
try {
|
||||
yield call(fetch, '/logout', { mode: 'no-cors', credentials: 'include' });
|
||||
} catch(err) {
|
||||
yield put({ type: LOGOUT_FAILURE, error: err });
|
||||
return;
|
||||
}
|
||||
|
||||
yield put({ type: LOGOUT_SUCCESS });
|
||||
}
|
||||
|
||||
export function* logoutSuccessSaga() {
|
||||
window.location.reload();
|
||||
}
|
@ -6,8 +6,8 @@ import { FETCH_ISSUES_REQUEST, ADD_LABEL_REQUEST, REMOVE_LABEL_REQUEST, CREATE_I
|
||||
import { fetchIssuesSaga, addLabelSaga, removeLabelSaga, createIssueSaga } from './issues';
|
||||
import { FETCH_PROJECTS_REQUEST } from '../actions/projects';
|
||||
import { fetchProjectsSaga } from './projects';
|
||||
import { LOGOUT } from '../actions/logout';
|
||||
import { logoutSaga } from './logout';
|
||||
import { LOGOUT_REQUEST, LOGOUT_SUCCESS } from '../actions/logout';
|
||||
import { logoutSaga, logoutSuccessSaga } from './logout';
|
||||
import { BUILD_KANBOARD_REQUEST, MOVE_CARD } from '../actions/kanboards';
|
||||
import { buildKanboardSaga, moveCardSaga, refreshKanboardSaga } from './kanboards';
|
||||
|
||||
@ -25,7 +25,8 @@ export function* rootSaga() {
|
||||
takeEvery(REMOVE_LABEL_REQUEST, removeLabelSaga),
|
||||
takeLatest(CREATE_ISSUE_REQUEST, createIssueSaga),
|
||||
takeLatest(CREATE_ISSUE_SUCCESS, refreshKanboardSaga),
|
||||
takeLatest(LOGOUT, logoutSaga)
|
||||
takeLatest(LOGOUT_REQUEST, logoutSaga),
|
||||
takeLatest(LOGOUT_SUCCESS, logoutSuccessSaga)
|
||||
]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user