set X-Lbry-Auth-Token for lbry.tv once email is verified
This commit is contained in:
parent
f1acf1cc1a
commit
7fe24fbf8b
2 changed files with 15 additions and 3 deletions
|
@ -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 => ({
|
||||
|
|
|
@ -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 (
|
||||
<div className={MAIN_WRAPPER_CLASS} ref={appRef} onContextMenu={e => openContextMenu(e)}>
|
||||
<Header />
|
||||
|
|
Loading…
Reference in a new issue