diff --git a/app/sagas/login.js b/app/sagas/login.js index 28843515d..1a9318806 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -20,7 +20,7 @@ import { inquiryRequest, inquiryReset } from '../ee/omnichannel/actions/inquiry' import { isOmnichannelStatusAvailable } from '../ee/omnichannel/lib'; import { RootEnum } from '../definitions'; import sdk from '../lib/services/sdk'; -import { TOKEN_KEY } from '../lib/constants'; +import { CURRENT_SERVER, TOKEN_KEY } from '../lib/constants'; import { getCustomEmojis, getEnterpriseModules, @@ -181,9 +181,9 @@ const handleLoginSuccess = function* handleLoginSuccess({ user }) { UserPreferences.setString(`${TOKEN_KEY}-${server}`, user.id); UserPreferences.setString(`${TOKEN_KEY}-${user.id}`, user.token); + UserPreferences.setString(CURRENT_SERVER, server); yield put(setUser(user)); EventEmitter.emit('connected'); - yield put(appStart({ root: RootEnum.ROOT_INSIDE })); const inviteLinkToken = yield select(state => state.inviteLinks.token); if (inviteLinkToken) { diff --git a/app/sagas/selectServer.js b/app/sagas/selectServer.js index b6669db01..9e65fa7bf 100644 --- a/app/sagas/selectServer.js +++ b/app/sagas/selectServer.js @@ -78,7 +78,6 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch yield put(encryptionStop()); yield put(clearActiveUsers()); const serversDB = database.servers; - UserPreferences.setString(CURRENT_SERVER, server); const userId = UserPreferences.getString(`${TOKEN_KEY}-${server}`); const userCollections = serversDB.get('users'); let user = null; @@ -117,6 +116,7 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch yield put(setUser(user)); yield connect({ server, logoutOnError: true }); yield put(appStart({ root: RootEnum.ROOT_INSIDE })); + UserPreferences.setString(CURRENT_SERVER, server); // only set server after have a user } else { yield put(clearUser()); yield connect({ server });