mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
convert post-api.login code to using async/await for Login.jsx
This commit is contained in:
parent
986d299961
commit
55586b9b2a
@ -41,7 +41,7 @@ class LoginPage extends Component {
|
|||||||
|
|
||||||
handlePasswordChange = value => this.safeSetState({ password: value, error: '' });
|
handlePasswordChange = value => this.safeSetState({ password: value, error: '' });
|
||||||
|
|
||||||
handleSubmit = event => {
|
handleSubmit = async event => {
|
||||||
const { username, password, loading } = this.state;
|
const { username, password, loading } = this.state;
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -49,15 +49,15 @@ class LoginPage extends Component {
|
|||||||
if (!loading) {
|
if (!loading) {
|
||||||
this.safeSetState({ loading: true });
|
this.safeSetState({ loading: true });
|
||||||
|
|
||||||
api.login(username, password)
|
try {
|
||||||
.catch(error => {
|
await api.login(username, password);
|
||||||
|
} catch (error) {
|
||||||
if (error.response.status === 401) {
|
if (error.response.status === 401) {
|
||||||
this.safeSetState({ error: LOGIN_ERROR_MESSAGE });
|
this.safeSetState({ error: LOGIN_ERROR_MESSAGE });
|
||||||
}
|
}
|
||||||
})
|
} finally {
|
||||||
.finally(() => {
|
|
||||||
this.safeSetState({ loading: false });
|
this.safeSetState({ loading: false });
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user