Merge pull request #560 from strapi/fix-update-user

Fix user update via API and content-type-builder
This commit is contained in:
Jim LAURIE 2018-02-05 17:46:40 +01:00 committed by GitHub
commit 2eabbbf847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 55 additions and 52 deletions

View File

@ -1,6 +1,6 @@
{
"private": true,
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"devDependencies": {
"assert": "~1.3.0",
"babel-eslint": "^6.1.2",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-admin",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Strapi Admin",
"repository": {
"type": "git",
@ -27,8 +27,8 @@
},
"devDependencies": {
"sanitize.css": "^4.1.0",
"strapi-helper-plugin": "3.0.0-alpha.9.1",
"strapi-utils": "3.0.0-alpha.9.1"
"strapi-helper-plugin": "3.0.0-alpha.9.2",
"strapi-utils": "3.0.0-alpha.9.2"
},
"author": {
"name": "Strapi",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-bookshelf",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Bookshelf hook for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [
@ -19,8 +19,8 @@
"bookshelf": "^0.10.3",
"lodash": "^4.17.4",
"pluralize": "^6.0.0",
"strapi-knex": "3.0.0-alpha.9.1",
"strapi-utils": "3.0.0-alpha.9.1"
"strapi-knex": "3.0.0-alpha.9.2",
"strapi-utils": "3.0.0-alpha.9.2"
},
"strapi": {
"isHook": true,

View File

@ -1,6 +1,6 @@
{
"name": "strapi-ejs",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "EJS hook for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-admin",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Generate the default admin panel for a Strapi application.",
"homepage": "http://strapi.io",
"keywords": [
@ -15,7 +15,7 @@
"dependencies": {
"fs-extra": "^4.0.1",
"lodash": "^4.17.4",
"strapi-admin": "3.0.0-alpha.9.1"
"strapi-admin": "3.0.0-alpha.9.2"
},
"author": {
"email": "hi@strapi.io",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-api",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Generate an API for a Strapi application.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-controller",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Generate a controller for a Strapi API.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-model",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Generate a model for a Strapi API.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-new",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Generate a new Strapi application.",
"homepage": "http://strapi.io",
"keywords": [
@ -18,7 +18,7 @@
"get-installed-path": "^3.0.1",
"inquirer": "^4.0.2",
"lodash": "^4.17.4",
"strapi-utils": "3.0.0-alpha.9.1",
"strapi-utils": "3.0.0-alpha.9.2",
"uuid": "^3.1.0"
},
"scripts": {

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-plugin",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Generate an plugin for a Strapi application.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-policy",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Generate a policy for a Strapi API.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-service",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Generate a service for a Strapi API.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Master of ceremonies for the Strapi generators.",
"homepage": "http://strapi.io",
"keywords": [
@ -17,7 +17,7 @@
"fs-extra": "^4.0.0",
"lodash": "^4.17.4",
"reportback": "^2.0.1",
"strapi-utils": "3.0.0-alpha.9.1"
"strapi-utils": "3.0.0-alpha.9.2"
},
"author": {
"name": "Strapi team",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-helper-plugin",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Helper for Strapi plugins development",
"engines": {
"node": ">= 8.0.0",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-knex",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Knex hook for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-middleware-views",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Views hook to enable server-side rendering for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-mongoose",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Mongoose hook for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [
@ -19,7 +19,7 @@
"mongoose": "^5.0.0-rc1",
"mongoose-float": "^1.0.2",
"pluralize": "^6.0.0",
"strapi-utils": "3.0.0-alpha.9.1"
"strapi-utils": "3.0.0-alpha.9.2"
},
"strapi": {
"isHook": true

View File

@ -1,6 +1,6 @@
{
"name": "strapi-plugin-content-manager",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "A powerful UI to easily manage your data.",
"strapi": {
"name": "Content Manager",
@ -24,7 +24,7 @@
},
"devDependencies": {
"react-select": "^1.0.0-rc.5",
"strapi-helper-plugin": "3.0.0-alpha.9.1"
"strapi-helper-plugin": "3.0.0-alpha.9.2"
},
"author": {
"name": "Strapi team",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-plugin-content-type-builder",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Strapi plugin to create content type (API).",
"strapi": {
"name": "Content Type Builder",
@ -24,11 +24,11 @@
},
"dependencies": {
"pluralize": "^7.0.0",
"strapi-generate": "3.0.0-alpha.9.1",
"strapi-generate-api": "3.0.0-alpha.9.1"
"strapi-generate": "3.0.0-alpha.9.2",
"strapi-generate-api": "3.0.0-alpha.9.2"
},
"devDependencies": {
"strapi-helper-plugin": "3.0.0-alpha.9.1"
"strapi-helper-plugin": "3.0.0-alpha.9.2"
},
"author": {
"name": "Strapi team",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-plugin-email",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "This is the description of the plugin.",
"strapi": {
"name": "Email",
@ -26,7 +26,7 @@
"sendmail": "^1.2.0"
},
"devDependencies": {
"strapi-helper-plugin": "3.0.0-alpha.9.1"
"strapi-helper-plugin": "3.0.0-alpha.9.2"
},
"author": {
"name": "Strapi team",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-plugin-settings-manager",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Strapi plugin to manage settings.",
"strapi": {
"name": "Settings Manager",
@ -25,7 +25,7 @@
"devDependencies": {
"flag-icon-css": "^2.8.0",
"react-select": "^1.0.0-rc.5",
"strapi-helper-plugin": "3.0.0-alpha.9.1"
"strapi-helper-plugin": "3.0.0-alpha.9.2"
},
"author": {
"name": "Strapi team",

View File

@ -97,9 +97,9 @@ module.exports = {
update: async (ctx, next) => {
try {
if (strapi.plugins['users-permissions'].config.advanced.unique_email && ctx.request.body.email) {
const user = await strapi.query('user', 'users-permissions').findOne({ email: ctx.request.body.email });
const users = await strapi.plugins['users-permissions'].services.user.fetchAll({ email: ctx.request.body.email });
if (user) {
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.');
}
}
@ -119,7 +119,7 @@ module.exports = {
email: ctx.request.body.email
});
if (user.id !== ctx.params.id) {
if ((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.');
}
}

View File

@ -1,6 +1,6 @@
{
"name": "strapi-plugin-users-permissions",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Protect your API with a full-authentication process based on JWT",
"strapi": {
"name": "Auth & Permissions",
@ -32,7 +32,7 @@
"uuid": "^3.1.0"
},
"devDependencies": {
"strapi-helper-plugin": "3.0.0-alpha.9.1"
"strapi-helper-plugin": "3.0.0-alpha.9.2"
},
"author": {
"name": "Strapi team",

View File

@ -48,6 +48,9 @@ module.exports = {
// Use Content Manager business logic to handle relation.
if (strapi.plugins['content-manager']) {
params.model = 'user';
params.id = (params._id || params.id);
return await strapi.plugins['content-manager'].services['contentmanager'].edit(params, values, 'users-permissions');
}

View File

@ -1,6 +1,6 @@
{
"name": "strapi-redis",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Redis hook for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [
@ -18,7 +18,7 @@
"ioredis": "^3.1.2",
"lodash": "^4.17.4",
"stack-trace": "0.0.10",
"strapi-utils": "3.0.0-alpha.9.1"
"strapi-utils": "3.0.0-alpha.9.2"
},
"strapi": {
"isHook": true

View File

@ -1,6 +1,6 @@
{
"name": "strapi-utils",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "Shared utilities for the Strapi packages",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi",
"version": "3.0.0-alpha.9.1",
"version": "3.0.0-alpha.9.2",
"description": "An open source solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier.",
"homepage": "http://strapi.io",
"keywords": [
@ -55,14 +55,14 @@
"rimraf": "^2.6.2",
"semver": "^5.4.1",
"stack-trace": "0.0.10",
"strapi-generate": "3.0.0-alpha.9.1",
"strapi-generate-admin": "3.0.0-alpha.9.1",
"strapi-generate-api": "3.0.0-alpha.9.1",
"strapi-generate-new": "3.0.0-alpha.9.1",
"strapi-generate-plugin": "3.0.0-alpha.9.1",
"strapi-generate-policy": "3.0.0-alpha.9.1",
"strapi-generate-service": "3.0.0-alpha.9.1",
"strapi-utils": "3.0.0-alpha.9.1"
"strapi-generate": "3.0.0-alpha.9.2",
"strapi-generate-admin": "3.0.0-alpha.9.2",
"strapi-generate-api": "3.0.0-alpha.9.2",
"strapi-generate-new": "3.0.0-alpha.9.2",
"strapi-generate-plugin": "3.0.0-alpha.9.2",
"strapi-generate-policy": "3.0.0-alpha.9.2",
"strapi-generate-service": "3.0.0-alpha.9.2",
"strapi-utils": "3.0.0-alpha.9.2"
},
"author": {
"email": "hi@strapi.io",