Skip to content

Commit 18b06c9

Browse files
committed
fix bugs in logout saga function + redirect user to homepage after logout
1 parent e267bc4 commit 18b06c9

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
Log of changes since the 2.0 version
44

55

6-
### Next release
7-
8-
- Show some stats of a deleted user on the changeset user panel
9-
- Add Mapping Team filter fields
10-
- Add forms to allow the creation and management of Mapping Teams
11-
- Code linting and text improvements
6+
### 0.60.0
127

8+
- disable logout when requests fails
9+
- adjust status modal position
1310

1411
### 0.58.2
1512

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "osmcha-frontend",
3-
"version": "0.59.0",
3+
"version": "0.60.0",
44
"license": "ISC",
55
"engines": {
66
"node": ">=7.0"

src/store/auth_actions.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @flow
22
import { put, call, take, select, all, takeLatest } from 'redux-saga/effects';
33
import { delay as delayPromise } from 'redux-saga';
4+
import { push } from 'react-router-redux';
45
import { fromJS } from 'immutable';
56

67
import {
@@ -49,6 +50,9 @@ export const logUserOut = () => action(AUTH.logout);
4950

5051
export const tokenSelector = (state: RootStateType) => state.auth.get('token');
5152

53+
export const locationSelector = (state: RootStateType) =>
54+
state.routing.location;
55+
5256
export const changesetIdSelector = (state: RootStateType) =>
5357
state.changeset.get('changesetId');
5458

@@ -121,7 +125,9 @@ export function* watchAuth(): any {
121125

122126
yield take(AUTH.logout);
123127
delayBy = DELAY;
124-
yield call(logoutFlow, delayBy);
128+
token = undefined;
129+
yield call(logoutFlow);
130+
yield call(delay, delayBy);
125131
} catch (error) {
126132
console.log(error);
127133
yield put(action(AUTH.loginError, error));
@@ -133,12 +139,16 @@ export function* watchAuth(): any {
133139
kind: 'warning'
134140
})
135141
);
142+
yield take(AUTH.logout);
136143
delayBy = 4 * delayBy;
144+
token = undefined;
145+
yield call(logoutFlow);
146+
yield call(delay, delayBy);
137147
}
138148
}
139149
}
140150

141-
export function* logoutFlow({ delayBy }: { delayBy: int }): any {
151+
export function* logoutFlow(): any {
142152
yield call(removeItem, 'token');
143153
yield call(removeItem, 'oauth_token');
144154
yield call(removeItem, 'oauth_token_secret');
@@ -150,7 +160,13 @@ export function* logoutFlow({ delayBy }: { delayBy: int }): any {
150160
yield put(action(CHANGESETS_PAGE.fetch, { pageIndex }));
151161
}
152162
yield put(action(AUTH.clearUserDetails));
153-
yield call(delay, delayBy);
163+
let location = yield select(locationSelector);
164+
yield put(
165+
push({
166+
...location,
167+
pathname: '/'
168+
})
169+
);
154170
}
155171

156172
export function* authTokenFlow(): any {

0 commit comments

Comments
 (0)