fix link token
This commit is contained in:
@@ -3,6 +3,7 @@ import React, { Component } from 'react';
|
||||
import "react-datepicker/dist/react-datepicker.css";
|
||||
import { HOST } from '../../config/index';
|
||||
import Store from '../../store';
|
||||
import { role } from '../../actions/role';
|
||||
class AutoLogin extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -24,11 +25,30 @@ class AutoLogin extends Component {
|
||||
if(this.props.match.params.token){
|
||||
localStorage.setItem("access_token", "Bearer " + this.props.match.params.token);
|
||||
Store.dispatch(login("Bearer " + this.props.match.params.token));
|
||||
window.location.href = "/";
|
||||
let data = fetch(`${HOST}/api/get_info`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': this.props.match.params.token,
|
||||
// 'Authorization': token,
|
||||
},
|
||||
}).then((response) => {
|
||||
return response.json()
|
||||
}).then((data) => {
|
||||
if(data.status === 10000){
|
||||
localStorage.setItem("roles", JSON.stringify(data.roles));
|
||||
Store.dispatch(role(data.roles));
|
||||
window.location.href = "/";
|
||||
}else{
|
||||
alert('Sai token!!!');
|
||||
window.location.href = "/login";
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
render() {
|
||||
console.log('oke',this.props.match)
|
||||
console.log('oke',Store.getState().role.role)
|
||||
return(
|
||||
<div></div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user