2019-08-31 04:07:25 +05:00
|
|
|
import { call, put } from 'redux-saga/effects';
|
|
|
|
|
2019-10-18 08:06:34 +05:00
|
|
|
import { authenticate, clearAuthenticateError } from '../../../actions';
|
2021-06-24 01:05:22 +05:00
|
|
|
import api from '../../../api';
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
export function* authenticateService(data) {
|
|
|
|
yield put(authenticate(data));
|
2021-06-24 01:05:22 +05:00
|
|
|
|
|
|
|
let accessToken;
|
|
|
|
try {
|
|
|
|
({ item: accessToken } = yield call(api.createAccessToken, data));
|
|
|
|
} catch (error) {
|
|
|
|
yield put(authenticate.failure(error));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
yield put(authenticate.success(accessToken));
|
2019-08-31 04:07:25 +05:00
|
|
|
}
|
|
|
|
|
2019-10-18 08:06:34 +05:00
|
|
|
export function* clearAuthenticateErrorService() {
|
|
|
|
yield put(clearAuthenticateError());
|
2019-08-31 04:07:25 +05:00
|
|
|
}
|