fix link token
This commit is contained in:
parent
12daa7b687
commit
58ebf27cf1
|
@ -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));
|
||||
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>
|
||||
)
|
||||
|
|
|
@ -37,6 +37,7 @@ class Header extends Component {
|
|||
}).then(data => {
|
||||
if (data.status === 10000) {
|
||||
Store.dispatch(setbox(data.data.company_id));
|
||||
localStorage.setItem("roles", JSON.stringify(data.data.roles));
|
||||
Store.dispatch(role(data.data.roles));
|
||||
this.setState({
|
||||
full_name: data.data.full_name
|
||||
|
|
|
@ -97,10 +97,10 @@ class MenuBar extends Component {
|
|||
</li>
|
||||
: ""}
|
||||
|
||||
{/* {this.state.dataRole?.indexOf('user:view') !== -1 ?
|
||||
{this.state.dataRole?.indexOf('user:view') !== -1 ?
|
||||
<li className="m-menu__item m-menu__item--submenu" aria-haspopup="true" m-menu-submenu-toggle="hover">
|
||||
<NavLink to="/user" className={"m-menu__link " + active} activeClassName="m-menu__item--active" onClick={() => this.onClickClose()}>
|
||||
<i className="text-navbar m-menu__link-icon fas fa-user-cog mr-2" />
|
||||
<i className="m-menu__link-icon fas fa-user-cog mr-2" style={{color: 'white'}} />
|
||||
<span className="m-menu__link-title">
|
||||
<span className="m-menu__link-wrap">
|
||||
<span className="text-navbar" style={{fontSize: 20, fontFamily: 'Roboto'}}>Quản lý người dùng</span>
|
||||
|
@ -108,12 +108,12 @@ class MenuBar extends Component {
|
|||
</span>
|
||||
</NavLink>
|
||||
</li>
|
||||
: ""} */}
|
||||
: ""}
|
||||
|
||||
{/* {this.state.dataRole?.indexOf('level:view') !== -1 ?
|
||||
{this.state.dataRole?.indexOf('level:view') !== -1 ?
|
||||
<li className="m-menu__item m-menu__item--submenu" aria-haspopup="true" m-menu-submenu-toggle="hover">
|
||||
<NavLink to="/role" className={"m-menu__link " + active} activeClassName="m-menu__item--active" onClick={() => this.onClickClose()}>
|
||||
<i className="text-navbar m-menu__link-icon fa fa-sitemap" />
|
||||
<i className="m-menu__link-icon fa fa-sitemap" style={{color: 'white'}} />
|
||||
<span className="m-menu__link-title">
|
||||
<span className="m-menu__link-wrap">
|
||||
<span className="text-navbar" style={{fontSize: 20, fontFamily: 'Roboto'}}>Thiết lập quyền</span>
|
||||
|
@ -121,12 +121,12 @@ class MenuBar extends Component {
|
|||
</span>
|
||||
</NavLink>
|
||||
</li>
|
||||
: ""} */}
|
||||
: ""}
|
||||
|
||||
{/* {this.state.dataRole?.indexOf('level:view') !== -1 ?
|
||||
{this.state.dataRole?.indexOf('level:view') !== -1 ?
|
||||
<li className="m-menu__item m-menu__item--submenu" aria-haspopup="true" m-menu-submenu-toggle="hover">
|
||||
<NavLink to="/test" className={"m-menu__link " + active} activeClassName="m-menu__item--active" onClick={() => this.onClickClose()}>
|
||||
<i className="text-navbar m-menu__link-icon fa fa-user-check" />
|
||||
<i className="m-menu__link-icon fa fa-user-check" style={{color: 'white'}} />
|
||||
<span className="m-menu__link-title">
|
||||
<span className="m-menu__link-wrap">
|
||||
<span className="text-navbar" style={{fontSize: 20, fontFamily: 'Roboto'}}>Độ chính xác</span>
|
||||
|
@ -134,7 +134,7 @@ class MenuBar extends Component {
|
|||
</span>
|
||||
</NavLink>
|
||||
</li>
|
||||
: ""} */}
|
||||
: ""}
|
||||
</ul>
|
||||
</div>
|
||||
{/* END: Aside Menu */}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import {ROLE} from '../../actions/role';
|
||||
|
||||
let roles = JSON.parse(localStorage.getItem('roles'));
|
||||
|
||||
const initialState = {
|
||||
role: null
|
||||
role: roles
|
||||
};
|
||||
export default function role(state = initialState, action) {
|
||||
switch(action.type){
|
||||
|
|
Loading…
Reference in New Issue
Block a user