[Admin] Login error message fix (#11747)

* fixed path to get error message Invalid Credentials

* improved lodash import
This commit is contained in:
ronronscelestes 2021-12-01 16:07:06 +01:00 committed by GitHub
parent 4b2d719e63
commit 23b4fb1d8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,8 @@
import React, { useEffect, useReducer } from 'react';
import axios from 'axios';
import { camelCase, get, omit } from 'lodash';
import camelCase from 'lodash/camelCase';
import get from 'lodash/get';
import omit from 'lodash/omit';
import { Redirect, useRouteMatch, useHistory } from 'react-router-dom';
import { auth, useQuery } from '@strapi/helper-plugin';
import PropTypes from 'prop-types';
@ -117,7 +119,11 @@ const AuthPage = ({ hasAdmin, setHasAdmin }) => {
push('/');
} catch (err) {
if (err.response) {
const errorMessage = get(err, ['response', 'data', 'message'], 'Something went wrong');
const errorMessage = get(
err,
['response', 'data', 'error', 'message'],
'Something went wrong'
);
if (camelCase(errorMessage).toLowerCase() === 'usernotactive') {
push('/auth/oops');