1componentDidMount() {
2 const { match: {params: { provider }}, location: { search } } = this.props;
3 const requestURL = `http://localhost:1337/auth/${provider}/callback${search}`;
4
5 request(requestURL, { method: 'GET' })
6 .then((response) => {
7 auth.setToken(response.jwt, true);
8 auth.setUserInfo(response.user, true);
9 this.redirectUser('/');
10 }).catch(err => {
11 console.log(err.response.payload)
12 this.redirectUser('/auth/login');
13 });
14}
15
16redirectUser = (path) => {
17 this.props.history.push(path);
18}