|
|
|
@ -27,7 +27,7 @@ import {
|
|
|
|
|
CarouselItem, |
|
|
|
|
CarouselControl |
|
|
|
|
} from 'reactstrap'; |
|
|
|
|
import { USER_LOGIN, USER_LOGIN_V2, CALERTUSER_SEARCH, MENU_MANAGEMENT, APP_MODE } from '../../../const/ApiConst.js'; |
|
|
|
|
import { USER_LOGIN, USER_LOGIN_V2, CALERTUSER_SEARCH, MENU_MANAGEMENT, APP_MODE, ROLE_SEARCH } from '../../../const/ApiConst.js'; |
|
|
|
|
import { appConfig, reloadConstants } from '../../../const/MapConst.js'; |
|
|
|
|
import { APP_NAME } from '../../../const/AppConst.js' |
|
|
|
|
import moment from "moment" |
|
|
|
@ -37,7 +37,7 @@ import logo_login_adw from '../../../assets/img/logo_adyawinsa.jpg'
|
|
|
|
|
import logo_login_kit from '../../../assets/img/logo_kit.png' |
|
|
|
|
import logo_login_nawakara from '../../../assets/img/logo_nawakara.png' |
|
|
|
|
import logo_login_si from '../../../assets/img/logo-surveyor-indonesia.png' |
|
|
|
|
import logo_ospro from '../../../assets/img/OSPRO.png' |
|
|
|
|
import logo_ospro '../../../assets/img/OSPRO.png' |
|
|
|
|
|
|
|
|
|
const antIcon = <LoadingOutlined style={{ fontSize: 24 }} spin />; |
|
|
|
|
|
|
|
|
@ -65,7 +65,8 @@ class Login extends Component {
|
|
|
|
|
emailState: '', |
|
|
|
|
}, |
|
|
|
|
loader: false, |
|
|
|
|
type: 'password' |
|
|
|
|
type: 'password', |
|
|
|
|
defaultPage: '' |
|
|
|
|
} |
|
|
|
|
this.handleChange = this.handleChange.bind(this); |
|
|
|
|
this.showHide = this.showHide.bind(this); |
|
|
|
@ -97,6 +98,41 @@ class Login extends Component {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getDataRole = async (token, role_id) => { |
|
|
|
|
const config = { |
|
|
|
|
headers: |
|
|
|
|
{ |
|
|
|
|
Authorization: `Bearer ${token}`, |
|
|
|
|
"Content-type": `application/json` |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
|
"paging": { "start": 0, "length": -1 }, |
|
|
|
|
"columns": [ |
|
|
|
|
{ "name": "id", "logic_operator": "=", "value": `${role_id}`, "operator": "AND" } |
|
|
|
|
], |
|
|
|
|
"joins": [ |
|
|
|
|
{ |
|
|
|
|
"name": "m_menu", |
|
|
|
|
"column_join": "default_page", |
|
|
|
|
"column_results": ["id", "name", "url"], |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
|
.post(ROLE_SEARCH, payload, config) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
let resData = result.data.data |
|
|
|
|
this.setState({defaultPage: resData[0].join_first_url}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getDataMenu = async (token, role_id) => { |
|
|
|
|
const config = { |
|
|
|
|
headers: |
|
|
|
@ -123,6 +159,14 @@ class Login extends Component {
|
|
|
|
|
else { |
|
|
|
|
this.props.history.push("/dashboard"); |
|
|
|
|
} |
|
|
|
|
if (this.state.defaultPage) { |
|
|
|
|
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"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
NotificationManager.error('Login Failed', 'Failed'); |
|
|
|
|
this.setState({ loader: false }) |
|
|
|
@ -164,6 +208,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) |
|
|
|
|
window.localStorage.setItem('isLogin', true); |
|
|
|
|
window.localStorage.setItem('token', access_token); |
|
|
|
|