Skip to content

Commit

Permalink
Implement handleUpdateTokenTTL saga
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstotsky committed Apr 23, 2024
1 parent 01e054f commit 8de37df
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/state/auth/saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}

0 comments on commit 8de37df

Please sign in to comment.