set lbry.tv header as soon as we get the auth_token cookie

This commit is contained in:
Sean Yesmunt 2019-10-24 12:06:38 -04:00
parent 6b61a544bc
commit 034cef3ed7
2 changed files with 4 additions and 6 deletions

View file

@ -12,7 +12,7 @@ import React, { Fragment, useState, useEffect } from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate, doOpenModal, doHideModal } from 'redux/actions/app';
import { doToast, isURIValid, setSearchApi } from 'lbry-redux';
import { Lbry, doToast, isURIValid, setSearchApi } from 'lbry-redux';
import { doUpdateIsNightAsync } from 'redux/actions/settings';
import {
doAuthenticate,
@ -30,6 +30,7 @@ import { formatLbryUriForWeb } from 'util/uri';
import { PersistGate } from 'redux-persist/integration/react';
import analytics from 'analytics';
import { getAuthToken, setAuthToken } from 'util/saved-passwords';
import { X_LBRY_AUTH_TOKEN } from 'constants/token';
// Import our app styles
// If a style is not necessary for the initial page load, it should be removed from `all.scss`
@ -109,6 +110,7 @@ Lbryio.setOverride(
// @endif
// @if TARGET='web'
const authToken = getAuthToken();
Lbry.setApiHeader(X_LBRY_AUTH_TOKEN, authToken);
resolve(authToken);
// @endif
}

View file

@ -7,7 +7,6 @@ import path from 'path';
import * as ACTIONS from 'constants/action_types';
import * as MODALS from 'constants/modal_types';
import * as PAGES from 'constants/pages';
import { X_LBRY_AUTH_TOKEN } from 'constants/token';
import {
Lbry,
doBalanceSubscribe,
@ -38,7 +37,7 @@ import { doAuthenticate, doGetSync } from 'lbryinc';
import { lbrySettings as config, version as appVersion } from 'package.json';
import { push } from 'connected-react-router';
import analytics from 'analytics';
import { deleteAuthToken, deleteSavedPassword, getSavedPassword, getAuthToken } from 'util/saved-passwords';
import { deleteAuthToken, deleteSavedPassword, getSavedPassword } from 'util/saved-passwords';
// @if TARGET='app'
const { autoUpdater } = remote.require('electron-updater');
@ -437,9 +436,6 @@ export function doAnalyticsView(uri, timeToStart) {
export function doSignIn() {
return (dispatch, getState) => {
// @if TARGET='web'
const authToken = getAuthToken();
Lbry.setApiHeader(X_LBRY_AUTH_TOKEN, authToken);
dispatch(doBalanceSubscribe());
dispatch(doFetchChannelListMine());
// @endif