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