make sure auth token header is set before any authenticated sdk calls are made

This commit is contained in:
Sean Yesmunt 2020-06-08 13:27:08 -04:00
parent 00306eff07
commit 36d60fabe4
21 changed files with 25 additions and 18771 deletions

View file

@ -1,80 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="/public/ui.js" async></script>
<link rel="icon" type="image/png" href="/public/favicon.png" />
<link rel="preload" href="/public/font/v1/300.woff" as="font" type="font/woff" />
<link rel="preload" href="/public/font/v1/300i.woff" as="font" type="font/woff" />
<link rel="preload" href="/public/font/v1/400.woff" as="font" type="font/woff" />
<link rel="preload" href="/public/font/v1/400i.woff" as="font" type="font/woff" />
<link rel="preload" href="/public/font/v1/700.woff" as="font" type="font/woff" />
<link rel="preload" href="/public/font/v1/700i.woff" as="font" type="font/woff" />
<style>
@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 300;
font-display: swap;
src: url('/public/font/v1/300.woff') format('woff');
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 300;
font-display: swap;
src: url('/public/font/v1/300i.woff') format('woff');
}
@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url('/public/font/v1/400.woff') format('woff');
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 400;
font-display: swap;
src: url('/public/font/v1/400i.woff') format('woff');
}
@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url('/public/font/v1/700.woff') format('woff');
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 700;
font-display: swap;
src: url('/public/font/v1/700i.woff') format('woff');
}
</style>
<!-- VARIABLE_HEAD_BEGIN -->
<title>lbry.tv</title>
<meta property="og:url" content="https://lbry.tv" />
<meta property="og:title" content="lbry.tv" />
<meta property="og:site_name" content="lbry.tv" />
<meta property="og:description" content="Meet LBRY, a content platform owned by everyone (and no one)." />
<meta property="og:image" content="https://lbry.tv/v1-og.png" />
<meta property="fb:app_id" content="1673146449633983" />
<!-- VARIABLE_HEAD_END -->
</head>
<body>
<div id="app"></div>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -1,210 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
viewBox="0 0 757.64 896.74"
version="1.1"
id="svg62"
sodipodi:docname="unlocklbry.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<metadata
id="metadata66">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>unlock</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1051"
id="namedview64"
showgrid="false"
inkscape:zoom="0.37218637"
inkscape:cx="97.177994"
inkscape:cy="700.34675"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg62" />
<defs
id="defs4">
<style
id="style2">.cls-1{fill:#f1f1f1;}.cls-2{fill:#e49d75;}.cls-3{fill:#5fc5d1;}.cls-4{fill:#6bd5e1;}.cls-5{fill:#e0e0e0;}.cls-6{fill:#a4a4a4;}.cls-7{fill:none;stroke:#e0e0e0;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px;}.cls-8{fill:#ffd98e;}.cls-9{fill:#ffe4ad;}.cls-10{fill-rule:evenodd;}</style>
</defs>
<title
id="title6">unlock</title>
<g
id="Layer_2"
data-name="Layer 2">
<g
id="vector">
<path
class="cls-1"
d="M636.5,232.73c68.06,61.33,93.17,180.88,67.33,286.61C677.81,625.07,601,717,496,778.29c-105,61.14-238,91.9-326.82,43.86S36.17,647.63,13.78,523.53c-22.2-124.11-22.56-245.67,36.58-305C109.5,159.4,228,162.31,342.79,165.22,457.62,168.31,568.62,171.41,636.5,232.73Z"
id="path8" />
<rect
class="cls-2"
x="558.8"
y="858.32"
width="22.08"
height="14.74"
id="rect10" />
<rect
class="cls-2"
x="677.14"
y="835.57"
width="20.72"
height="18.36"
transform="translate(-378.13 619.59) rotate(-38.93)"
id="rect12" />
<rect
class="cls-2"
x="586.33"
y="256.37"
width="17.47"
height="20.69"
rx="8.23"
id="rect14" />
<path
class="cls-3"
d="M602.4,567.42c3,6.88,26,144.94,29.38,158s57.45,98.2,61.13,103.29c1.13,7.36-15.57,19.81-23.49,19.81C661.5,842.26,569,708.23,566.78,702.28S557.11,553.94,602.4,567.42Z"
id="path16"
style="fill:#4b8576;fill-opacity:1" />
<path
class="cls-4"
d="M505.83,544.55c-1.05,5.7,14.58,136,16.52,153.5s31.89,158.48,34.54,162,22.81,2.76,26.29,1-6.8-147-6.8-157.53,27-107.65,23.53-135.78S505.83,544.55,505.83,544.55Z"
id="path18"
style="fill:#257761;fill-opacity:1" />
<rect
class="cls-2"
x="561.36"
y="386.6"
width="21.11"
height="36.74"
id="rect20" />
<rect
class="cls-5"
x="94.97"
y="137.85"
width="379.57"
height="379.57"
rx="22.42"
id="rect22" />
<path
class="cls-6"
d="M308.48,310.8a35.09,35.09,0,1,0-47.45,0L234,420.41H335.48Z"
id="path24" />
<path
class="cls-7"
d="M162.9,137.85a121.86,121.86,0,0,1,243.71,0"
id="path26" />
<ellipse
class="cls-2"
cx="569.19"
cy="353.64"
rx="29"
ry="39"
id="ellipse28" />
<path
class="cls-8"
d="M565.24,415.77c-35.16,0-66.5,97.54-60.48,129.91,1.78,9.56,85.92,28.85,98.78,26.15C608.11,565.61,626.76,415.77,565.24,415.77Z"
id="path30"
style="fill:#fff58c;fill-opacity:1" />
<path
class="cls-9"
d="M556.22,470.1c15.74-11.42-9.42-66.76-15.3-67.71-10.83-1.75-37.76,19-36.91,27.72C504.46,434.71,540.19,481.73,556.22,470.1Z"
id="path32"
style="fill:#fff58c;fill-opacity:1" />
<path
class="cls-2"
d="M509,426c-4.24-5.09-14.84-30-16-35.91s-4-94.74-4-100S482,271.56,482,263.64s8.06-18.66,12.16-18.8c4.38,3.11,10.46,21.35,10.74,26,1.53-10,8.77-12.3,10.75-12.3s1.72,15.45-6.48,25.85c.29,7.64,10,83.31,11.57,87.69s19.45,33.09,19.41,35.63S509,426,509,426Z"
id="path34" />
<rect
class="cls-6"
x="368.05"
y="260.35"
width="358.11"
height="10.23"
transform="translate(40.99 -71.64) rotate(7.78)"
id="rect36" />
<rect
class="cls-6"
x="366.9"
y="247.63"
width="21.9"
height="29.63"
transform="translate(39.02 -48.75) rotate(7.78)"
id="rect38" />
<rect
class="cls-6"
x="397.87"
y="251.17"
width="11.78"
height="29.63"
transform="translate(39.74 -52.22) rotate(7.78)"
id="rect40" />
<path
class="cls-2"
d="M604.74,334c-.83-4.74-1.58-39.09-.3-43.94s4.74-8.39,6.29-15.63c.53-2.49-.31-11.11-2-11.47-3.64-.78-3.85,3.3-4.33,6.3-1.86,10.23-5.65,8.36-7.4,8.12s-7.76-1.28-9.73-1.33,3.05,4,1.52,10.47c-1.2,5.09-6.84,39-8,44.55C585,331.24,604.74,334,604.74,334Z"
id="path42" />
<rect
class="cls-6"
x="417.79"
y="253.89"
width="11.78"
height="29.63"
transform="translate(40.29 -54.9) rotate(7.78)"
id="rect44" />
<rect
class="cls-6"
x="368.01"
y="250.51"
width="63.09"
height="10.5"
transform="translate(38.31 -51.75) rotate(7.78)"
id="rect46" />
<path
class="cls-6"
d="M734.69,264.08A26.54,26.54,0,1,0,757.4,294,26.54,26.54,0,0,0,734.69,264.08ZM749,292.82a18.07,18.07,0,1,1-15.45-20.35A18.07,18.07,0,0,1,749,292.82Z"
id="path48" />
<path
class="cls-2"
d="M509.28,284.31c-1.32-5.17-3.89-9.69-4.31-13.58l0,.12c-.28-4.66-6.36-22.9-10.74-26-4.1.14-12.16,10.88-12.16,18.8,0,5.81,3.8,14.5,5.82,20.79h21.35v0Z"
id="path50" />
<path
d="M543.06,329.21c0,13.49,9.52,21.81,24.61,26.45,0,18.46,2.85,19.27,2.85,30.51,0,24.22-4.13,12.11-4.13,53.93,0,25.22,10.56,38.94,30,38.94,23.51,0,37-24.87,37-38.27,0-17-16.82-46.54-18-71.07-1.63-33-11.89-60.61-37.62-60.61C555.79,309.09,543.06,317.27,543.06,329.21Z"
id="path52" />
<circle
class="cls-2"
cx="569.16"
cy="358.82"
r="7.8"
id="circle54" />
<path
class="cls-10"
d="M701.29,842.49l12.5,17.06-26.15,37-24.68.16.32-12.51,9.91-4.38L682,858.08Z"
id="path56" />
<polyline
points="582.36 871.83 582.36 896.74 509.14 896.74 509.14 885.71 557.45 871.83 582.36 871.83"
id="polyline58" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 7.2 KiB

18472
lbrytv/dist/public/ui.js vendored

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

View file

@ -227,7 +227,6 @@ function App(props: Props) {
// Keep this at the end to ensure initial setup effects are run first
useEffect(() => {
// Wait for balance to be populated on desktop so we know when we can begin syncing
if (!hasSignedIn && hasVerifiedEmail) {
signIn();
setHasSignedIn(true);

View file

@ -47,8 +47,7 @@ import {
import { doAuthenticate, doGetSync, doClaimRewardType, rewards as REWARDS } from 'lbryinc';
import { lbrySettings as config, version as appVersion } from 'package.json';
import analytics, { SHARE_INTERNAL } from 'analytics';
import { doSignOutCleanup, deleteSavedPassword, getSavedPassword, getAuthToken } from 'util/saved-passwords';
import { X_LBRY_AUTH_TOKEN } from 'constants/token';
import { doSignOutCleanup, deleteSavedPassword, getSavedPassword } from 'util/saved-passwords';
// @if TARGET='app'
const { autoUpdater } = remote.require('electron-updater');
@ -504,8 +503,6 @@ export function doAnaltyicsPurchaseEvent(fileInfo) {
export function doSignIn() {
return (dispatch, getState) => {
// @if TARGET='web'
const authToken = getAuthToken();
Lbry.setApiHeader(X_LBRY_AUTH_TOKEN, authToken);
dispatch(doBalanceSubscribe());
dispatch(doFetchChannelListMine());
// @endif

View file

@ -9,11 +9,12 @@ import thunk from 'redux-thunk';
import { createMemoryHistory, createBrowserHistory } from 'history';
import { routerMiddleware } from 'connected-react-router';
import createRootReducer from './reducers';
import { buildSharedStateMiddleware, ACTIONS as LBRY_REDUX_ACTIONS, SETTINGS } from 'lbry-redux';
import { doGetSync, selectUserVerifiedEmail } from 'lbryinc';
import { getSavedPassword } from 'util/saved-passwords';
import { Lbry, buildSharedStateMiddleware, ACTIONS as LBRY_REDUX_ACTIONS, SETTINGS } from 'lbry-redux';
import { LBRYINC_ACTIONS, doGetSync, selectUserVerifiedEmail } from 'lbryinc';
import { getSavedPassword, getAuthToken } from 'util/saved-passwords';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { generateInitialUrl } from 'util/url';
import { X_LBRY_AUTH_TOKEN } from 'constants/token';
function isFunction(object) {
return typeof object === 'function';
@ -159,11 +160,30 @@ const sharedStateCb = ({ dispatch, getState }) => {
}
};
const populateAuthTokenHeader = () => {
return next => action => {
if (action.type === LBRYINC_ACTIONS.AUTHENTICATION_SUCCESS) {
const authToken = getAuthToken();
Lbry.setApiHeader(X_LBRY_AUTH_TOKEN, authToken);
}
next(action);
};
};
const sharedStateMiddleware = buildSharedStateMiddleware(triggerSharedStateActions, sharedStateFilters, sharedStateCb);
const rootReducer = createRootReducer(history);
const persistedReducer = persistReducer(persistOptions, rootReducer);
const bulkThunk = createBulkThunkMiddleware();
const middleware = [sharedStateMiddleware, routerMiddleware(history), thunk, bulkThunk];
const middleware = [
sharedStateMiddleware,
// @if TARGET='web'
populateAuthTokenHeader,
// @endif
routerMiddleware(history),
thunk,
bulkThunk,
];
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
enableBatching(persistedReducer),