This commit is contained in:
Alex Gleason 2021-03-26 16:42:47 -05:00
parent 597546e989
commit 20ef262cfc
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 6 additions and 6 deletions

View file

@ -127,8 +127,9 @@ export function otpVerify(code, mfa_token) {
code: code,
challenge_type: 'totp',
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
}).then(response => {
dispatch(authLoggedIn(response.data));
}).then(({ data: token }) => {
dispatch(authLoggedIn(token));
return token;
});
};
}

View file

@ -2,8 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { injectIntl, FormattedMessage, defineMessages } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { otpVerify } from 'soapbox/actions/auth';
import { fetchMe } from 'soapbox/actions/me';
import { otpVerify, verifyCredentials } from 'soapbox/actions/auth';
import { SimpleInput } from 'soapbox/features/forms';
import PropTypes from 'prop-types';
@ -36,9 +35,9 @@ class OtpAuthForm extends ImmutablePureComponent {
handleSubmit = (event) => {
const { dispatch, mfa_token } = this.props;
const { code } = this.getFormData(event.target);
dispatch(otpVerify(code, mfa_token)).then(() => {
dispatch(otpVerify(code, mfa_token)).then(({ access_token }) => {
this.setState({ code_error: false });
return dispatch(fetchMe());
return dispatch(verifyCredentials(access_token));
}).catch(error => {
this.setState({ isLoading: false });
if (error.response.data.error === 'Invalid code') {