Send auth token to lbry.tv once email is verified #2716
4 changed files with 21 additions and 3 deletions
5
src/platforms/web/fs.js
Normal file
5
src/platforms/web/fs.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
export default {
|
||||||
|
readFileSync: () => undefined,
|
||||||
|
accessFileSync: () => undefined,
|
||||||
|
constants: {},
|
||||||
|
};
|
|
@ -1,13 +1,14 @@
|
||||||
import { hot } from 'react-hot-loader/root';
|
import { hot } from 'react-hot-loader/root';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doUpdateBlockHeight, doError, doFetchTransactions } from 'lbry-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 { selectThemePath } from 'redux/selectors/settings';
|
||||||
import App from './view';
|
import App from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
user: selectUser(state),
|
user: selectUser(state),
|
||||||
theme: selectThemePath(state),
|
theme: selectThemePath(state),
|
||||||
|
accessToken: selectAccessToken(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React, { useEffect, useRef } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import analytics from 'analytics';
|
import analytics from 'analytics';
|
||||||
|
import { Lbry } from 'lbry-redux';
|
||||||
import Router from 'component/router/index';
|
import Router from 'component/router/index';
|
||||||
import ModalRouter from 'modal/modalRouter';
|
import ModalRouter from 'modal/modalRouter';
|
||||||
import ReactModal from 'react-modal';
|
import ReactModal from 'react-modal';
|
||||||
|
@ -17,17 +18,19 @@ type Props = {
|
||||||
pageTitle: ?string,
|
pageTitle: ?string,
|
||||||
language: string,
|
language: string,
|
||||||
theme: string,
|
theme: string,
|
||||||
user: ?{ id: string },
|
accessToken: ?string,
|
||||||
|
user: ?{ id: string, has_verified_email: boolean },
|
||||||
fetchRewards: () => void,
|
fetchRewards: () => void,
|
||||||
fetchRewardedContent: () => void,
|
fetchRewardedContent: () => void,
|
||||||
fetchTransactions: () => void,
|
fetchTransactions: () => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
function App(props: Props) {
|
function App(props: Props) {
|
||||||
const { theme, fetchRewards, fetchRewardedContent, fetchTransactions, user } = props;
|
const { theme, fetchRewards, fetchRewardedContent, fetchTransactions, user, accessToken } = props;
|
||||||
const appRef = useRef();
|
const appRef = useRef();
|
||||||
const isEnhancedLayout = useKonamiListener();
|
const isEnhancedLayout = useKonamiListener();
|
||||||
const userId = user && user.id;
|
const userId = user && user.id;
|
||||||
|
const hasVerifiedEmail = user && user.has_verified_email;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ReactModal.setAppElement(appRef.current);
|
ReactModal.setAppElement(appRef.current);
|
||||||
|
@ -50,6 +53,14 @@ function App(props: Props) {
|
||||||
}
|
}
|
||||||
}, [userId]);
|
}, [userId]);
|
||||||
|
|
||||||
|
// @if TARGET='web'
|
||||||
|
useEffect(() => {
|
||||||
|
if (hasVerifiedEmail && accessToken) {
|
||||||
|
Lbry.setApiHeader('X-Lbry-Auth-Token', accessToken);
|
||||||
|
}
|
||||||
|
}, [hasVerifiedEmail, accessToken]);
|
||||||
|
// @endif
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={MAIN_WRAPPER_CLASS} ref={appRef} onContextMenu={e => openContextMenu(e)}>
|
<div className={MAIN_WRAPPER_CLASS} ref={appRef} onContextMenu={e => openContextMenu(e)}>
|
||||||
<Header />
|
<Header />
|
||||||
|
|
|
@ -41,6 +41,7 @@ const webConfig = {
|
||||||
|
|
||||||
alias: {
|
alias: {
|
||||||
electron: path.resolve(__dirname, 'src/platforms/web/stubs'),
|
electron: path.resolve(__dirname, 'src/platforms/web/stubs'),
|
||||||
|
fs: path.resolve(__dirname, 'src/platforms/web/fs'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|
Loading…
Reference in a new issue