mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
Fix administrator edition
This commit is contained in:
parent
718aeccf3c
commit
efa57a37fa
@ -85,10 +85,13 @@ module.exports = ({ model }) => ({
|
||||
patch: true,
|
||||
})
|
||||
.catch(err => {
|
||||
const field = _.last(_.words(err.detail.split('=')[0]));
|
||||
const error = { message: `This ${field} is already taken`, field };
|
||||
if (err && err.detail) {
|
||||
const field = _.last(_.words(err.detail.split('=')[0]));
|
||||
const error = { message: `This ${field} is already taken`, field };
|
||||
throw error;
|
||||
}
|
||||
|
||||
throw error;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -134,6 +134,14 @@ module.exports = {
|
||||
update: async ctx => {
|
||||
const values = ctx.request.body;
|
||||
|
||||
const admin = await strapi.admin
|
||||
.queries('administrator', 'admin')
|
||||
.findOne(ctx.params);
|
||||
|
||||
if (values.password === admin.password) {
|
||||
delete values.password;
|
||||
}
|
||||
|
||||
if (values.password) {
|
||||
values.password = await strapi.plugins[
|
||||
'users-permissions'
|
||||
@ -142,7 +150,7 @@ module.exports = {
|
||||
|
||||
const data = await strapi.admin
|
||||
.queries('administrator', 'admin')
|
||||
.update(Object.assign({}, ctx.params, values));
|
||||
.update(ctx.params, values);
|
||||
|
||||
// Send 200 `ok`
|
||||
ctx.send(data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user