Skip to content

Commit

Permalink
Merge a2e9473 into 97ce3b8
Browse files Browse the repository at this point in the history
  • Loading branch information
patlub committed Feb 19, 2018
2 parents 97ce3b8 + a2e9473 commit f6f3fce
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions app/js/components/manageApps/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
import React, { Component } from 'react';
import { hashHistory } from 'react-router';
import axios from 'axios';
import { ApiHelper } from '../../helpers/apiHelper';
import { Form, Button, FormControl, FormGroup, Col, ControlLabel, Checkbox, Nav, Modal } from 'react-bootstrap';
class Login extends Component {
constructor(props) {
super(props);
this.state = {
username: '',
password: '',
show: false
}
show: false,
checkLoggedInComplete: false
};

this.handleLogin = this.handleLogin.bind(this);
this.handleShow = this.handleShow.bind(this);
this.handleClose = this.handleClose.bind(this);
}

componentWillMount(){
this.checkLoginStatus();
}

checkLoginStatus(){
this.fetchLocation('/v1/session').then((response) => {
this.setState({checkLoggedInComplete: true});
response.authenticated ? hashHistory.push('/') : null;
});
}

fetchLocation(url) {
const apiHelper = new ApiHelper(null);
return new Promise(function(resolve, reject) {
apiHelper.get(url).then(response => {
resolve(response);
});
});
}

handleClose() {
this.setState({ show: false });
}

handleShow() {
this.setState({ show: true });
}
Expand Down Expand Up @@ -47,6 +72,7 @@ class Login extends Component {

render() {
return (
this.state.checkLoggedInComplete &&
<div className="well">
<a href="../../">
<img src="img/openmrs-with-title-small.png" />
Expand Down

0 comments on commit f6f3fce

Please sign in to comment.