Merge branch 'auth-fetch-login' into 'develop'
Authenticated fetch: postpone fetching the instance See merge request soapbox-pub/soapbox-fe!707
This commit is contained in:
commit
71a6615219
3 changed files with 16 additions and 5 deletions
|
@ -32,9 +32,14 @@ const validLocale = locale => Object.keys(messages).includes(locale);
|
|||
export const store = configureStore();
|
||||
|
||||
store.dispatch(preload());
|
||||
store.dispatch(fetchMe());
|
||||
store.dispatch(fetchInstance());
|
||||
store.dispatch(fetchSoapboxConfig());
|
||||
|
||||
store.dispatch(fetchMe())
|
||||
.then(() => {
|
||||
// Postpone for authenticated fetch
|
||||
store.dispatch(fetchInstance());
|
||||
store.dispatch(fetchSoapboxConfig());
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const me = state.get('me');
|
||||
|
|
|
@ -6,6 +6,7 @@ import { injectIntl } from 'react-intl';
|
|||
import LoginForm from './login_form';
|
||||
import OtpAuthForm from './otp_auth_form';
|
||||
import { logIn, verifyCredentials, switchAccount } from 'soapbox/actions/auth';
|
||||
import { fetchInstance } from 'soapbox/actions/instance';
|
||||
import { isStandalone } from 'soapbox/utils/state';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
|
@ -40,7 +41,9 @@ class LoginPage extends ImmutablePureComponent {
|
|||
const { dispatch, intl, me } = this.props;
|
||||
const { username, password } = this.getFormData(event.target);
|
||||
dispatch(logIn(intl, username, password)).then(({ access_token }) => {
|
||||
return dispatch(verifyCredentials(access_token));
|
||||
return dispatch(verifyCredentials(access_token))
|
||||
// Refetch the instance for authenticated fetch
|
||||
.then(() => dispatch(fetchInstance()));
|
||||
}).then(account => {
|
||||
this.setState({ shouldRedirect: true });
|
||||
if (typeof me === 'string') {
|
||||
|
|
|
@ -9,6 +9,7 @@ import SoapboxPropTypes from 'soapbox/utils/soapbox_prop_types';
|
|||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
import PropTypes from 'prop-types';
|
||||
import { logIn, verifyCredentials } from 'soapbox/actions/auth';
|
||||
import { fetchInstance } from 'soapbox/actions/instance';
|
||||
import OtpAuthForm from 'soapbox/features/auth_login/components/otp_auth_form';
|
||||
import IconButton from 'soapbox/components/icon_button';
|
||||
|
||||
|
@ -55,7 +56,9 @@ class Header extends ImmutablePureComponent {
|
|||
const { dispatch, intl } = this.props;
|
||||
const { username, password } = this.getFormData(event.target);
|
||||
dispatch(logIn(intl, username, password)).then(({ access_token }) => {
|
||||
return dispatch(verifyCredentials(access_token));
|
||||
return dispatch(verifyCredentials(access_token))
|
||||
// Refetch the instance for authenticated fetch
|
||||
.then(() => dispatch(fetchInstance()));
|
||||
}).catch(error => {
|
||||
if (error.response.data.error === 'mfa_required') {
|
||||
this.setState({ mfa_auth_needed: true, mfa_token: error.response.data.mfa_token });
|
||||
|
|
Loading…
Reference in a new issue