Merge branch 'auth-form-improvements' into 'develop'

LoginForm: properly convey "isLoading" state

See merge request soapbox-pub/soapbox-fe!254
inline_pdf
Alex Gleason 2020-09-26 02:39:47 +00:00
commit bc2aaca5da
2 zmienionych plików z 41 dodań i 39 usunięć

Wyświetl plik

@ -20,17 +20,18 @@ class LoginPage extends ImmutablePureComponent {
this.handleSubmit = this.handleSubmit.bind(this);
}
state = {
isLoading: false,
mfa_auth_needed: false,
mfa_token: '',
}
getFormData = (form) => {
return Object.fromEntries(
Array.from(form).map(i => [i.name, i.value])
);
}
state = {
mfa_auth_needed: false,
mfa_token: '',
}
handleSubmit = (event) => {
const { dispatch } = this.props;
const { username, password } = this.getFormData(event.target);
@ -47,8 +48,8 @@ class LoginPage extends ImmutablePureComponent {
}
render() {
const { me, isLoading } = this.props;
const { mfa_auth_needed, mfa_token } = this.state;
const { me } = this.props;
const { isLoading, mfa_auth_needed, mfa_token } = this.state;
if (me) return <Redirect to='/' />;
if (mfa_auth_needed) return <OtpAuthForm mfa_token={mfa_token} />;

Wyświetl plik

@ -36,6 +36,12 @@ class Header extends ImmutablePureComponent {
this.handleSubmit = this.handleSubmit.bind(this);
}
state = {
isLoading: false,
mfa_auth_needed: false,
mfa_token: '',
}
getFormData = (form) => {
return Object.fromEntries(
Array.from(form).map(i => [i.name, i.value])
@ -71,14 +77,9 @@ class Header extends ImmutablePureComponent {
intl: PropTypes.object.isRequired,
}
state = {
mfa_auth_needed: false,
mfa_token: '',
}
render() {
const { me, instance, isLoading, intl } = this.props;
const { mfa_auth_needed, mfa_token } = this.state;
const { me, instance, intl } = this.props;
const { isLoading, mfa_auth_needed, mfa_token } = this.state;
return (
<nav className='header'>