From 4bd6f6b9cfa84fe63954d8ab5912865f409547d9 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 26 Jul 2022 14:37:58 +0300 Subject: [PATCH] Add token refreshing on re-login via ws --- src/state/ws/signIn.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/state/ws/signIn.js b/src/state/ws/signIn.js index 870e9939c..dc3f7e578 100644 --- a/src/state/ws/signIn.js +++ b/src/state/ws/signIn.js @@ -1,8 +1,14 @@ -import { call, take, race } from 'redux-saga/effects' +import { + call, + put, + take, + race, +} from 'redux-saga/effects' import { delay } from 'redux-saga' import WS from 'state/ws' import types from 'state/auth/constants' +import actions from 'state/auth/actions' const RETRIES = 6 @@ -18,6 +24,11 @@ function* wsSignIn(retryCount = 0) { return yield call(wsSignIn, retryCount + 1) } + if (wsAuth) { + const { payload: { result } } = wsAuth + yield put(actions.updateAuth(result)) + } + return !!wsAuth }