From 8de37dfe83e23cee0c2b569a9d6189fa01c0fe13 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 17 Apr 2024 14:07:45 +0300 Subject: [PATCH] Implement handleUpdateTokenTTL saga --- src/state/auth/saga.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/state/auth/saga.js b/src/state/auth/saga.js index b98c4ea05..a04aad811 100644 --- a/src/state/auth/saga.js +++ b/src/state/auth/saga.js @@ -513,6 +513,24 @@ function* handleSyncAfterUpdate({ payload }) { } } +function* handleUpdateTokenTTL({ payload }) { + try { + const auth = yield select(selectAuth) + const params = { authTokenTTLSec: payload } + const { error } = yield makeFetchCall('updateUser', params, auth) + + if (error) { + yield put(updateErrorStatus({ + id: 'status.fail', + topic: 'auth.updateUser', + detail: error?.message ?? JSON.stringify(error), + })) + } + } catch (fail) { + yield put(updateAuthErrorStatus(fail)) + } +} + export default function* authSaga() { yield takeLatest(types.CHECK_AUTH, checkAuth) yield takeLatest(types.FETCH_USERS, fetchUsers) @@ -528,5 +546,6 @@ export default function* authSaga() { yield takeLatest(types.REMOVE_USER, removeUser) yield takeLatest(types.AUTH_EXPIRED, handleExpiredAuth) yield takeLatest(types.SET_SYNC_AFTER_UPDATE, handleSyncAfterUpdate) + yield takeLatest(types.SET_TOKEN_TTL, handleUpdateTokenTTL) yield fork(tokenRefreshSaga) }