|
|
|
@ -66,7 +66,7 @@ class Login extends Component {
|
|
|
|
|
}, |
|
|
|
|
loader: false, |
|
|
|
|
type: 'password', |
|
|
|
|
defaultPage: '' |
|
|
|
|
defaultPage: '' |
|
|
|
|
} |
|
|
|
|
this.handleChange = this.handleChange.bind(this); |
|
|
|
|
this.showHide = this.showHide.bind(this); |
|
|
|
@ -98,8 +98,8 @@ class Login extends Component {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getDataRole = async (token, role_id) => { |
|
|
|
|
const config = { |
|
|
|
|
getDataRole = async (token, role_id) => { |
|
|
|
|
const config = { |
|
|
|
|
headers: |
|
|
|
|
{ |
|
|
|
|
Authorization: `Bearer ${token}`, |
|
|
|
@ -113,12 +113,12 @@ class Login extends Component {
|
|
|
|
|
{ "name": "id", "logic_operator": "=", "value": `${role_id}`, "operator": "AND" } |
|
|
|
|
], |
|
|
|
|
"joins": [ |
|
|
|
|
{ |
|
|
|
|
"name": "m_menu", |
|
|
|
|
"column_join": "default_page", |
|
|
|
|
"column_results": ["id", "name", "url"], |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
{ |
|
|
|
|
"name": "m_menu", |
|
|
|
|
"column_join": "default_page", |
|
|
|
|
"column_results": ["id", "name", "url"], |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -129,9 +129,9 @@ class Login extends Component {
|
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
let resData = result.data.data |
|
|
|
|
this.setState({defaultPage: resData[0].join_first_url}) |
|
|
|
|
this.setState({ defaultPage: resData[0].join_first_url }) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getDataMenu = async (token, role_id) => { |
|
|
|
|
const config = { |
|
|
|
@ -159,9 +159,9 @@ class Login extends Component {
|
|
|
|
|
else { |
|
|
|
|
this.props.history.push("/dashboard"); |
|
|
|
|
} |
|
|
|
|
if (this.state.defaultPage) { |
|
|
|
|
if (this.state.defaultPage) { |
|
|
|
|
this.props.history.push(this.state.defaultPage); |
|
|
|
|
} else if (role_id == 28) { |
|
|
|
|
} else if (role_id == 28) { |
|
|
|
|
this.props.history.push("/dashboard-customer/58/63"); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
@ -208,13 +208,14 @@ 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.getDataRole(access_token, data_user.role_id) |
|
|
|
|
this.getDataMenu(access_token, data_user.role_id) |
|
|
|
|
window.localStorage.setItem('isLogin', true); |
|
|
|
|
window.localStorage.setItem('token', access_token); |
|
|
|
|
window.localStorage.setItem('user_id', data_user.id); |
|
|
|
|
window.localStorage.setItem('user_name', data_user.name); |
|
|
|
|
window.localStorage.setItem('role_id', data_user.role_id); |
|
|
|
|
window.localStorage.setItem('company_id', data_user.company_id); |
|
|
|
|
} else { |
|
|
|
|
console.log("kode : ", doLogin.data.code); |
|
|
|
|
// NotificationManager.error('Cek username atau password anda!', 'Gagal Login!');
|
|
|
|
|