diff --git a/app/soapbox/actions/auth.js b/app/soapbox/actions/auth.js index 98deb2e1d..e99ad9fdb 100644 --- a/app/soapbox/actions/auth.js +++ b/app/soapbox/actions/auth.js @@ -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; }); }; } diff --git a/app/soapbox/features/auth_login/components/otp_auth_form.js b/app/soapbox/features/auth_login/components/otp_auth_form.js index 091d2a48f..438e24bff 100644 --- a/app/soapbox/features/auth_login/components/otp_auth_form.js +++ b/app/soapbox/features/auth_login/components/otp_auth_form.js @@ -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') {