diff options
Diffstat (limited to 'vnext/src/index.js')
-rw-r--r-- | vnext/src/index.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/vnext/src/index.js b/vnext/src/index.js index 9527178e..9dbf21e7 100644 --- a/vnext/src/index.js +++ b/vnext/src/index.js @@ -15,11 +15,14 @@ import Footer from './components/Footer'; import Avatar from './components/Avatar'; import Header from './components/Header'; +import { me } from './api'; + class App extends React.Component { constructor(props) { super(props); let params = qs.parse(window.location.search) if (params.hash) { + localStorage.visitor = JSON.stringify({uid: 0, hash: params.hash}); window.history.replaceState({}, document.title, `${window.location.protocol}//${window.location.host}${window.location.pathname}`) } this.state = { @@ -30,6 +33,13 @@ class App extends React.Component { }; } + componentDidMount() { + const {hash, uid} = this.state.visitor; + if (uid === 0 && hash) { + me().then(visitor => this.auth(visitor)) + } + } + render() { const user = this.state.visitor; return ( |