|
@@ -7,18 +7,18 @@ import token from '../../../utils/token'
|
|
|
// worker-saga for signing in
|
|
|
|
|
|
export default function* ({ payload: { login, password } }) {
|
|
|
- try {
|
|
|
- const payload = yield call(() =>
|
|
|
- axios.get(`${SIGN_IN_URL}login=${login}&password=${password}`)
|
|
|
- .then(({ data: [payload] }) => payload)
|
|
|
- );
|
|
|
+ try {
|
|
|
+ const payload = yield call(() =>
|
|
|
+ axios.get(`${SIGN_IN_URL}login=${login}&password=${password}`)
|
|
|
+ .then(({ data: [payload] }) => payload)
|
|
|
+ );
|
|
|
|
|
|
- yield call(() => { if (!payload) throw (new Error("No such email or password")) });
|
|
|
- yield put(actions.signInRequestSucces(payload));
|
|
|
- yield call(() => localStorage.setItem(token, JSON.stringify(payload)));
|
|
|
- }
|
|
|
- catch ({ message }) {
|
|
|
- yield put(actions.signInRequestFailure(message));
|
|
|
- yield call(() => localStorage.removeItem(token));
|
|
|
- }
|
|
|
+ yield call(() => { if (!payload) throw (new Error("No such email or password")) });
|
|
|
+ yield put(actions.signInRequestSucces(payload));
|
|
|
+ yield call(() => localStorage.setItem(token, JSON.stringify(payload)));
|
|
|
+ }
|
|
|
+ catch ({ message }) {
|
|
|
+ yield put(actions.signInRequestFailure(message));
|
|
|
+ yield call(() => localStorage.removeItem(token));
|
|
|
+ }
|
|
|
}
|