Skip to content

Commit

Permalink
In the login dialog, don't tell the user credentials are invalid when…
Browse files Browse the repository at this point in the history
… in fact the server couldn't be reached. Fixes #4704.
  • Loading branch information
fniessink committed Jul 9, 2023
1 parent 845e9fe commit a367a80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
23 changes: 16 additions & 7 deletions components/frontend/src/header_footer/Menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,40 @@ import './Menubar.css';
function Login({ set_user }) {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [login_error, setLoginError] = useState(false);
const [error, setError] = useState('');

function submit() {
login(username, password)
.then(function (json) {
if (json.ok) {
set_user(username, json.email, new Date(Date.parse(json.session_expiration_datetime)))
} else {
setLoginError(true);
setError("credentials");
}
})
.catch(function (_error) {
setLoginError(true);
setError("connection");
});
}

let messageHeader = "Heads up"
let messageContent = "Changes you make after you log in, such as adding metrics, changing metric targets, and marking issues as false positive, are logged."
if (error === "connection") {
messageHeader = "Connection error"
messageContent = "Can't reach the server. Please check your connection."
}
if (error === "credentials") {
messageHeader = "Invalid credentials"
messageContent = "Username and/or password are invalid. Please try again."
}
return (
<Modal trigger={<Button secondary><Icon name='user' />Login</Button>} size='tiny' onClose={() => setLoginError(false)} >
<Modal trigger={<Button secondary><Icon name='user' />Login</Button>} size='tiny' onClose={() => setError("")} >
<Modal.Header content='Login' />
<Modal.Content>
<Form error={login_error} warning={!login_error} onSubmit={() => submit()} >
<Form error={!!error} warning={!error} onSubmit={() => submit()} >
<Form.Input autoFocus id='username' name='username' label='Username' onChange={(_event, { value }) => setUsername(value)} />
<Form.Input id='password' name='password' type='password' label='Password' onChange={(_event, { value }) => setPassword(value)} />
<Message error header='Invalid credentials' content='Username and/or password are invalid. Please try again.' />
<Message warning header='Heads up' content='Changes you make after you log in, such as adding metrics, changing metric targets, and marking issues as false positive, are logged.' />
<Message error={!!error} warning={!error} header={messageHeader} content={messageContent} />
<Form.Button>Submit</Form.Button>
</Form>
</Modal.Content>
Expand Down
1 change: 1 addition & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ If your currently installed *Quality-time* version is v4.10.0 or older, please r

### Fixed

- In the login dialog, don't tell the user credentials are invalid when in fact the server couldn't be reached. Fixes [#4704](https://github.com/ICTU/quality-time/issues/4704).
- When changing the metric type, tags in the tags field would not be updated immediately. Fixes [#5116](https://github.com/ICTU/quality-time/issues/5116).
- Show warning message when the user session expires. Fixes [#5327](https://github.com/ICTU/quality-time/issues/5327).
- Fix the landing URL for Harbor artifacts. Fixes [#6485](https://github.com/ICTU/quality-time/issues/6485)
Expand Down

0 comments on commit a367a80

Please sign in to comment.