equal
deleted
inserted
replaced
98 function* watchLoginRequest(context) { |
98 function* watchLoginRequest(context) { |
99 while (true) { |
99 while (true) { |
100 try { |
100 try { |
101 |
101 |
102 const { username, password } = yield take(types.AUTH_LOGIN_REQUEST); |
102 const { username, password } = yield take(types.AUTH_LOGIN_REQUEST); |
103 const client = context['client']; |
103 const client = context.client; |
104 const response = yield client.post('/api/auth/login/', { username, password }); |
104 const response = yield client.post('/api/auth/login/', { username, password }); |
105 |
105 |
106 localStorage.setItem('currentUser', JSON.stringify(response.user)); |
106 localStorage.setItem('currentUser', JSON.stringify(response.user)); |
107 localStorage.setItem('token', response.token); |
107 localStorage.setItem('token', response.token); |
108 |
108 |
133 const { token } = yield take(types.AUTH_STORE_TOKEN_ASYNC); |
133 const { token } = yield take(types.AUTH_STORE_TOKEN_ASYNC); |
134 yield put({ type: types.AUTH_STORE_TOKEN, token }); |
134 yield put({ type: types.AUTH_STORE_TOKEN, token }); |
135 } |
135 } |
136 } |
136 } |
137 |
137 |
138 function* watchUpdateSettings() { |
138 function* watchUpdateSettings(context) { |
139 while (true) { |
139 while (true) { |
140 const { username, firstname, lastname } = yield take(types.USER_UPDATE_SETTINGS_ASYNC); |
140 const { username, firstname, lastname } = yield take(types.USER_UPDATE_SETTINGS_ASYNC); |
|
141 const client = context.client; |
141 try { |
142 try { |
142 yield client.put('/api/auth/user/', { |
143 yield client.put('/api/auth/user/', { |
143 username, |
144 username, |
144 first_name: firstname, |
145 first_name: firstname, |
145 last_name: lastname |
146 last_name: lastname |
161 watchCreateSession(), |
162 watchCreateSession(), |
162 watchUpdateSession(), |
163 watchUpdateSession(), |
163 watchLoginSubmit(), |
164 watchLoginSubmit(), |
164 watchLoginRequest(context), |
165 watchLoginRequest(context), |
165 watchStoreToken(), |
166 watchStoreToken(), |
166 watchUpdateSettings(), |
167 watchUpdateSettings(context), |
167 ]) |
168 ]) |
168 } |
169 } |