mirror of
https://github.com/strapi/strapi.git
synced 2025-10-14 17:43:01 +00:00
Merge branch 'master' into strapi-upload-rackspace
This commit is contained in:
commit
e015270a32
@ -1,5 +1,5 @@
|
|||||||
import { LOCATION_CHANGE } from 'react-router-redux';
|
import { LOCATION_CHANGE } from 'react-router-redux';
|
||||||
import { findIndex, get, isArray, isEmpty, isNumber, isString, map } from 'lodash';
|
import { findIndex, get, isArray, isEmpty, includes, isNumber, isString, map } from 'lodash';
|
||||||
import {
|
import {
|
||||||
call,
|
call,
|
||||||
cancel,
|
cancel,
|
||||||
@ -64,6 +64,7 @@ export function* submit() {
|
|||||||
const isCreating = yield select(makeSelectIsCreating());
|
const isCreating = yield select(makeSelectIsCreating());
|
||||||
const record = yield select(makeSelectRecord());
|
const record = yield select(makeSelectRecord());
|
||||||
const source = yield select(makeSelectSource());
|
const source = yield select(makeSelectSource());
|
||||||
|
let shouldAddTranslationSuffix = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Show button loader
|
// Show button loader
|
||||||
@ -122,6 +123,12 @@ export function* submit() {
|
|||||||
if (isArray(err.response.payload.message)) {
|
if (isArray(err.response.payload.message)) {
|
||||||
const errors = err.response.payload.message.reduce((acc, current) => {
|
const errors = err.response.payload.message.reduce((acc, current) => {
|
||||||
const error = current.messages.reduce((acc, current) => {
|
const error = current.messages.reduce((acc, current) => {
|
||||||
|
if (includes(current.id, 'Auth')) {
|
||||||
|
acc.id = `users-permissions.${current.id}`;
|
||||||
|
shouldAddTranslationSuffix = true;
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
acc.errorMessage = current.id;
|
acc.errorMessage = current.id;
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
@ -131,11 +138,13 @@ export function* submit() {
|
|||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const name = get(err.response.payload.message, ['0', 'messages', '0', 'field']);
|
const name = get(err.response.payload.message, ['0', 'messages', '0', 'field', '0']);
|
||||||
|
|
||||||
yield put(setFormErrors([{ name, errors }]));
|
yield put(setFormErrors([{ name, errors }]));
|
||||||
}
|
}
|
||||||
strapi.notification.error(isCreating ? 'content-manager.error.record.create' : 'content-manager.error.record.update');
|
|
||||||
|
const notifErrorPrefix = source === 'users-permissions' && shouldAddTranslationSuffix ? 'users-permissions.' : '';
|
||||||
|
strapi.notification.error(`${notifErrorPrefix}${get(err.response, ['payload', 'message', '0', 'messages', '0', 'id'], isCreating ? 'content-manager.error.record.create' : 'content-manager.error.record.update')}`);
|
||||||
} finally {
|
} finally {
|
||||||
yield put(unsetLoader());
|
yield put(unsetLoader());
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ module.exports = {
|
|||||||
const user = await strapi.query('user', 'users-permissions').findOne({ email: ctx.request.body.email });
|
const user = await strapi.query('user', 'users-permissions').findOne({ email: ctx.request.body.email });
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.email.taken' }] }] : 'Email is already taken.');
|
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.email.taken', field: ['email'] }] }] : 'Email is already taken.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ module.exports = {
|
|||||||
const users = await strapi.plugins['users-permissions'].services.user.fetchAll({ email: ctx.request.body.email });
|
const users = await strapi.plugins['users-permissions'].services.user.fetchAll({ email: ctx.request.body.email });
|
||||||
|
|
||||||
if (users && _.find(users, user => (user.id || user._id).toString() !== ctx.params.id)) {
|
if (users && _.find(users, user => (user.id || user._id).toString() !== ctx.params.id)) {
|
||||||
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.email.taken' }] }] : 'Email is already taken.');
|
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.email.taken', field: ['email'] }] }] : 'Email is already taken.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (user !== null && (user.id || user._id).toString() !== ctx.params.id) {
|
if (user !== null && (user.id || user._id).toString() !== ctx.params.id) {
|
||||||
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.email.taken' }] }] : 'Email is already taken.');
|
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.email.taken', field: ['email'] }] }] : 'Email is already taken.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user