From 660cc823d4f2446dbc3113b2de4d3164664303fb Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 27 Jun 2018 16:32:53 +0300 Subject: fix social login --- vnext/src/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'vnext/src/index.js') 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 ( -- cgit v1.2.3