|
|
@ -120,7 +120,7 @@ class Login extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getDataMenu = async (token, role_id, hierarchy, user_id, company_id, role_name, all_project, user_name) => { |
|
|
|
getDataMenu = async (token, role_id, hierarchy, user_id, company_id, role_name, all_project, user_name, configApp) => { |
|
|
|
const config = { |
|
|
|
const config = { |
|
|
|
headers: |
|
|
|
headers: |
|
|
|
{ |
|
|
|
{ |
|
|
@ -147,17 +147,18 @@ class Login extends Component { |
|
|
|
this.props.history.push({ |
|
|
|
this.props.history.push({ |
|
|
|
pathname: "/dashboard", |
|
|
|
pathname: "/dashboard", |
|
|
|
state: { |
|
|
|
state: { |
|
|
|
menu_login: JSON.stringify(resData), |
|
|
|
menu_login: JSON.stringify(resData), |
|
|
|
hierarchy, |
|
|
|
hierarchy, |
|
|
|
role_id, |
|
|
|
role_id, |
|
|
|
user_id, |
|
|
|
user_id, |
|
|
|
token, |
|
|
|
token, |
|
|
|
isLogin: true, |
|
|
|
isLogin: true, |
|
|
|
company_id, |
|
|
|
company_id, |
|
|
|
role_name, |
|
|
|
role_name, |
|
|
|
all_project, |
|
|
|
all_project, |
|
|
|
user_name |
|
|
|
user_name, |
|
|
|
} |
|
|
|
configApp |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.state.defaultPage) { |
|
|
|
if (this.state.defaultPage) { |
|
|
@ -165,17 +166,18 @@ class Login extends Component { |
|
|
|
this.props.history.push({ |
|
|
|
this.props.history.push({ |
|
|
|
pathname: this.state.defaultPage, |
|
|
|
pathname: this.state.defaultPage, |
|
|
|
state: { |
|
|
|
state: { |
|
|
|
menu_login: JSON.stringify(resData), |
|
|
|
menu_login: JSON.stringify(resData), |
|
|
|
hierarchy, |
|
|
|
hierarchy, |
|
|
|
role_id, |
|
|
|
role_id, |
|
|
|
user_id, |
|
|
|
user_id, |
|
|
|
token, |
|
|
|
token, |
|
|
|
isLogin: true, |
|
|
|
isLogin: true, |
|
|
|
company_id, |
|
|
|
company_id, |
|
|
|
role_name, |
|
|
|
role_name, |
|
|
|
all_project, |
|
|
|
all_project, |
|
|
|
user_name |
|
|
|
user_name, |
|
|
|
} |
|
|
|
configApp |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.props.history.push(this.state.defaultPage); |
|
|
|
this.props.history.push(this.state.defaultPage); |
|
|
@ -187,17 +189,17 @@ class Login extends Component { |
|
|
|
this.props.history.push({ |
|
|
|
this.props.history.push({ |
|
|
|
pathname: "/dashboard", |
|
|
|
pathname: "/dashboard", |
|
|
|
state: { |
|
|
|
state: { |
|
|
|
menu_login: JSON.stringify(resData), |
|
|
|
menu_login: JSON.stringify(resData), |
|
|
|
hierarchy, |
|
|
|
hierarchy, |
|
|
|
role_id, |
|
|
|
role_id, |
|
|
|
user_id, |
|
|
|
user_id, |
|
|
|
token, |
|
|
|
token, |
|
|
|
isLogin: true, |
|
|
|
isLogin: true, |
|
|
|
company_id, |
|
|
|
company_id, |
|
|
|
role_name, |
|
|
|
role_name, |
|
|
|
all_project, |
|
|
|
all_project, |
|
|
|
user_name |
|
|
|
user_name |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -242,7 +244,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.hierarchy, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project, data_user.user_name) |
|
|
|
this.getDataMenu(access_token, data_user.role_id, data_user.hierarchy, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project, data_user.user_name, data_user.configApp) |
|
|
|
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); |
|
|
@ -252,6 +254,7 @@ class Login extends Component { |
|
|
|
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('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)); |
|
|
|
|
|
|
|
window.localStorage.setItem('configApp', JSON.stringify(data_user.configApp)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// NotificationManager.error('Cek username atau password anda!', 'Gagal Login!');
|
|
|
|
// NotificationManager.error('Cek username atau password anda!', 'Gagal Login!');
|
|
|
|
NotificationManager.error(doLogin.data.message, 'Login Failed!'); |
|
|
|
NotificationManager.error(doLogin.data.message, 'Login Failed!'); |
|
|
|