1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00
planka/client/src/sagas/login/services/login.js

30 lines
717 B
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
import { call, put } from 'redux-saga/effects';
2022-08-04 13:31:14 +02:00
import actions from '../../../actions';
import api from '../../../api';
import { setAccessToken } from '../../../utils/access-token-storage';
2019-08-31 04:07:25 +05:00
2022-08-04 13:31:14 +02:00
export function* authenticate(data) {
yield put(actions.authenticate(data));
let accessToken;
try {
({ item: accessToken } = yield call(api.createAccessToken, data));
} catch (error) {
2022-08-04 13:31:14 +02:00
yield put(actions.authenticate.failure(error));
return;
}
yield call(setAccessToken, accessToken);
2022-08-04 13:31:14 +02:00
yield put(actions.authenticate.success(accessToken));
2019-08-31 04:07:25 +05:00
}
2022-08-04 13:31:14 +02:00
export function* clearAuthenticateError() {
yield put(actions.clearAuthenticateError());
2019-08-31 04:07:25 +05:00
}
2022-08-04 13:31:14 +02:00
export default {
authenticate,
clearAuthenticateError,
};