Browse Source

handle login customer

pull/1/head
wahyuun 1 year ago
parent
commit
b3e23efb77
  1. 23
      src/views/Pages/Login/Login.js

23
src/views/Pages/Login/Login.js

@ -133,7 +133,7 @@ class Login extends Component {
}
}
getDataMenu = async (token, role_id) => {
getDataMenu = async (token, role_id,user_id) => {
const config = {
headers:
{
@ -157,15 +157,28 @@ class Login extends Component {
this.props.history.push("/dashboard-customer/58/63");
}
else {
this.props.history.push("/dashboard");
this.props.history.push({
pathname: "/dashboard",
state: { role_id: role_id, user_id: user_id }
});
}
if (this.state.defaultPage) {
this.props.history.push(this.state.defaultPage);
if (role_id === 44) {
this.props.history.push({
pathname: this.state.defaultPage,
state: { role_id: role_id, user_id: user_id }
});
} else {
this.props.history.push(this.state.defaultPage);
}
} else if (role_id == 28) {
this.props.history.push("/dashboard-customer/58/63");
}
else {
this.props.history.push("/dashboard");
this.props.history.push({
pathname: "/dashboard",
state: { role_id: role_id, user_id: user_id }
});
}
} else {
NotificationManager.error('Login Failed', 'Failed');
@ -209,7 +222,7 @@ class Login extends Component {
if (doLogin && doLogin.data && doLogin.data.code === 200) {
const { access_token, data_user } = doLogin.data.data
this.getDataRole(access_token, data_user.role_id)
this.getDataMenu(access_token, data_user.role_id)
this.getDataMenu(access_token, data_user.role_id, data_user.id)
window.localStorage.setItem('isLogin', true);
window.localStorage.setItem('token', access_token);
window.localStorage.setItem('user_id', data_user.id);

Loading…
Cancel
Save