link token
This commit is contained in:
38
app/src/components/AutoLogin/AutoLogin.js
Normal file
38
app/src/components/AutoLogin/AutoLogin.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { login } from 'actions/isLogin';
|
||||
import React, { Component } from 'react';
|
||||
import "react-datepicker/dist/react-datepicker.css";
|
||||
import { HOST } from '../../config/index';
|
||||
import Store from '../../store';
|
||||
class AutoLogin extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
dataRole: Store.getState().role.role,
|
||||
isLogin: Store.getState().isLogin.isLogin,
|
||||
};
|
||||
Store.subscribe(() => {
|
||||
this.setState({
|
||||
isLogin: Store.getState().isLogin.isLogin,
|
||||
dataRole: Store.getState().role.role,
|
||||
}, () => {
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
componentDidMount() {
|
||||
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 = "/";
|
||||
}
|
||||
}
|
||||
render() {
|
||||
console.log('oke',this.props.match)
|
||||
return(
|
||||
<div></div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default AutoLogin;
|
||||
Reference in New Issue
Block a user