Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions login-view/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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());
});
};


Expand All @@ -110,6 +114,7 @@ function App() {
<Typography component="h1" variant="h5">
Sign in
</Typography>
<ErrorMessage error={error}/>
<form className={classes.form} noValidate onSubmit={handleSubmit}>
<TextField
variant="outlined"
Expand Down
19 changes: 19 additions & 0 deletions login-view/src/components/ErrorMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, {Component} from 'react';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles(theme => ({
error: {
color: '#ff0000',
},
}));

function ErrorMessage(props) {
const classes = useStyles();
return (
<div className={classes.error}>
{props.error}
</div>
)
}

export default ErrorMessage;
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public void run() {
Assert.assertEquals(400, statusCode);
Status status = Config.getInstance().getMapper().readValue(body, Status.class);
Assert.assertNotNull(status);
Assert.assertEquals("ERR12001", status.getCode());
Assert.assertEquals("ERR11004", status.getCode());
} catch (Exception e) {
logger.error("IOException: ", e);
throw new ClientException(e);
Expand Down