|
|
@ -133,7 +133,7 @@ class Login extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getDataMenu = async (token, role_id, user_id, company_id, role_name) => { |
|
|
|
getDataMenu = async (token, role_id, user_id, company_id, role_name, all_project) => { |
|
|
|
const config = { |
|
|
|
const config = { |
|
|
|
headers: |
|
|
|
headers: |
|
|
|
{ |
|
|
|
{ |
|
|
@ -159,14 +159,14 @@ class Login extends Component { |
|
|
|
else { |
|
|
|
else { |
|
|
|
this.props.history.push({ |
|
|
|
this.props.history.push({ |
|
|
|
pathname: "/dashboard", |
|
|
|
pathname: "/dashboard", |
|
|
|
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name } |
|
|
|
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name, all_project: all_project } |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.state.defaultPage) { |
|
|
|
if (this.state.defaultPage) { |
|
|
|
if (role_id === 44) { |
|
|
|
if (role_id === 44) { |
|
|
|
this.props.history.push({ |
|
|
|
this.props.history.push({ |
|
|
|
pathname: this.state.defaultPage, |
|
|
|
pathname: this.state.defaultPage, |
|
|
|
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name } |
|
|
|
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name, all_project: all_project } |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.props.history.push(this.state.defaultPage); |
|
|
|
this.props.history.push(this.state.defaultPage); |
|
|
@ -222,7 +222,7 @@ class Login extends Component { |
|
|
|
if (doLogin && doLogin.data && doLogin.data.code === 200) { |
|
|
|
if (doLogin && doLogin.data && doLogin.data.code === 200) { |
|
|
|
const { access_token, data_user } = doLogin.data.data |
|
|
|
const { access_token, data_user } = doLogin.data.data |
|
|
|
this.getDataRole(access_token, data_user.role_id) |
|
|
|
this.getDataRole(access_token, data_user.role_id) |
|
|
|
this.getDataMenu(access_token, data_user.role_id, data_user.id, data_user.company_id, data_user.role.name) |
|
|
|
this.getDataMenu(access_token, data_user.role_id, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project) |
|
|
|
window.localStorage.setItem('isLogin', true); |
|
|
|
window.localStorage.setItem('isLogin', true); |
|
|
|
window.localStorage.setItem('token', access_token); |
|
|
|
window.localStorage.setItem('token', access_token); |
|
|
|
window.localStorage.setItem('user_id', data_user.id); |
|
|
|
window.localStorage.setItem('user_id', data_user.id); |
|
|
@ -230,6 +230,7 @@ class Login extends Component { |
|
|
|
window.localStorage.setItem('role_id', data_user.role_id); |
|
|
|
window.localStorage.setItem('role_id', data_user.role_id); |
|
|
|
window.localStorage.setItem('company_id', data_user.company_id); |
|
|
|
window.localStorage.setItem('company_id', data_user.company_id); |
|
|
|
window.localStorage.setItem('role_name', data_user.role.name); |
|
|
|
window.localStorage.setItem('role_name', data_user.role.name); |
|
|
|
|
|
|
|
window.localStorage.setItem('all_project', data_user.role.all_project); |
|
|
|
window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy)); |
|
|
|
window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// NotificationManager.error('Cek username atau password anda!', 'Gagal Login!');
|
|
|
|
// NotificationManager.error('Cek username atau password anda!', 'Gagal Login!');
|
|
|
|