diff --git a/login-view/src/App.js b/login-view/src/App.js
index e1dac87a..d5cb76bc 100644
--- a/login-view/src/App.js
+++ b/login-view/src/App.js
@@ -9,6 +9,7 @@ import LockOutlinedIcon from '@material-ui/icons/LockOutlined';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
import Container from '@material-ui/core/Container';
+import ErrorMessage from './components/ErrorMessage';
const useStyles = makeStyles(theme => ({
'@global': {
@@ -48,6 +49,7 @@ function App() {
const [clientId] = useState(params.get('client_id') == null ? '' : params.get('client_id'));
const [userType] = useState(params.get('user_type') == null ? '' : params.get('user_type'));
const [redirectUri] = useState(params.get('redirect_uri') == null ? '' : params.get('redirect_uri'));
+ const [error, setError] = useState('');
const handleChangeUsername = e => {
setUsername(e.target.value)
@@ -78,25 +80,27 @@ function App() {
const formData = Object.keys(data).map(key => encodeURIComponent(key) + '=' + encodeURIComponent(data[key])).join('&');
console.log(formData);
- // const formData = new URLSearchParams();
- // formData.append('j_username', {username});
- // formData.append('j_password', {password});
-
- // var formData = new FormData();
- // for (var k in data) {
- // formData.append(k, data[k]);
- // }
fetch("/oauth2/code", {
method: 'POST',
+ redirect: 'follow',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: formData
})
- .then(response => response.json())
- .then(data => console.log(data))
- .catch(error => console.log(error));
+ .then(response => {
+ // HTTP redirect.
+ if (response.ok && response.redirected) {
+ window.location.href = response.url;
+ } else {
+ throw Error(response.statusText);
+ }
+ })
+ .catch(error => {
+ console.log("error=", error);
+ setError(error.toString());
+ });
};
@@ -110,6 +114,7 @@ function App() {
Sign in
+