From 7fe24fbf8b954f3443568dda7f77ed356fa10322 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 6 Aug 2019 12:00:31 -0400 Subject: [PATCH 1/2] set X-Lbry-Auth-Token for lbry.tv once email is verified --- src/ui/component/app/index.js | 3 ++- src/ui/component/app/view.jsx | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/ui/component/app/index.js b/src/ui/component/app/index.js index 8e1482f5e..7184dad9f 100644 --- a/src/ui/component/app/index.js +++ b/src/ui/component/app/index.js @@ -1,13 +1,14 @@ import { hot } from 'react-hot-loader/root'; import { connect } from 'react-redux'; import { doUpdateBlockHeight, doError, doFetchTransactions } from 'lbry-redux'; -import { selectUser, doRewardList, doFetchRewardedContent } from 'lbryinc'; +import { selectUser, doRewardList, doFetchRewardedContent, selectAccessToken } from 'lbryinc'; import { selectThemePath } from 'redux/selectors/settings'; import App from './view'; const select = state => ({ user: selectUser(state), theme: selectThemePath(state), + accessToken: selectAccessToken(state), }); const perform = dispatch => ({ diff --git a/src/ui/component/app/view.jsx b/src/ui/component/app/view.jsx index 938099c58..4205e835c 100644 --- a/src/ui/component/app/view.jsx +++ b/src/ui/component/app/view.jsx @@ -1,6 +1,7 @@ // @flow import React, { useEffect, useRef } from 'react'; import analytics from 'analytics'; +import { Lbry } from 'lbry-redux'; import Router from 'component/router/index'; import ModalRouter from 'modal/modalRouter'; import ReactModal from 'react-modal'; @@ -17,17 +18,19 @@ type Props = { pageTitle: ?string, language: string, theme: string, - user: ?{ id: string }, + accessToken: ?string, + user: ?{ id: string, has_verified_email: boolean }, fetchRewards: () => void, fetchRewardedContent: () => void, fetchTransactions: () => void, }; function App(props: Props) { - const { theme, fetchRewards, fetchRewardedContent, fetchTransactions, user } = props; + const { theme, fetchRewards, fetchRewardedContent, fetchTransactions, user, accessToken } = props; const appRef = useRef(); const isEnhancedLayout = useKonamiListener(); const userId = user && user.id; + const hasVerifiedEmail = user && user.has_verified_email; useEffect(() => { ReactModal.setAppElement(appRef.current); @@ -50,6 +53,14 @@ function App(props: Props) { } }, [userId]); + // @if TARGET='web' + useEffect(() => { + if (hasVerifiedEmail && accessToken) { + Lbry.setApiHeader('X-Lbry-Auth-Token', accessToken); + } + }, [hasVerifiedEmail, accessToken]); + // @endif + return (
openContextMenu(e)}>
-- 2.45.2 From fe0a57719adc255e17e70424ecf72e17e3abcaea Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 6 Aug 2019 12:16:56 -0400 Subject: [PATCH 2/2] fix: web build --- src/platforms/web/fs.js | 5 +++++ webpack.web.config.js | 1 + 2 files changed, 6 insertions(+) create mode 100644 src/platforms/web/fs.js diff --git a/src/platforms/web/fs.js b/src/platforms/web/fs.js new file mode 100644 index 000000000..1dcedefc5 --- /dev/null +++ b/src/platforms/web/fs.js @@ -0,0 +1,5 @@ +export default { + readFileSync: () => undefined, + accessFileSync: () => undefined, + constants: {}, +}; diff --git a/webpack.web.config.js b/webpack.web.config.js index 4bf7bd1d5..31fe91f95 100644 --- a/webpack.web.config.js +++ b/webpack.web.config.js @@ -41,6 +41,7 @@ const webConfig = { alias: { electron: path.resolve(__dirname, 'src/platforms/web/stubs'), + fs: path.resolve(__dirname, 'src/platforms/web/fs'), }, }, plugins: [ -- 2.45.2