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

View file

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