diff --git a/ROADMAP.md b/ROADMAP.md index 9de51a92b8..9811dce9f7 100755 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -88,21 +88,21 @@ _Reorganize the mono-repository. The rule to follow is to only have hooks withou - ~~Improve generated APIs (especially the relation part)~~. `strapi@alpha.8` *(expected release date: 22/12/2017)*: -- [Admin] Install plugins directly from the interface. -- Ask database settings during the project creation. -- Ping database before generating the project. -- Allow associations between app's models and plugins' models. +- ~~[Admin] Install plugins directly from the interface~~. +- ~~Ask database settings during the project creation~~. +- ~~Ping database before generating the project~~. +- ~~Allow associations between app's models and plugins' models~~. `strapi@alpha.9` *(expected release date: 12/01/2018)*: -- [Plugin - Users & Permissions] Integrate providers authentication, email templates and advanced settings. +- ~~[Plugin] Analytics (homepage only)~~. +- ~~[Plugin - Users & Permissions] Integrate providers authentication, email templates and advanced settings~~. -`strapi@alpha.10` *(expected release date: 29/01/2018)*: -- [Plugin] Analytics. +`strapi@alpha.10` *(expected release date: 15/02/2018)*: +- [Framework] New core API to manage settings in database. +- [Admin] Refactor the Input component to make it more extensible. -`strapi@alpha.11` *(expected release date: 12/02/2018)*: +`strapi@alpha.11` *(expected release date: 02/03/2018)*: - [Plugin] Upload. -- Re-design & improve the DX of the validations layer. -`strapi@alpha.12` *(expected release date: 02/03/2018)*: -- [Plugin] Media Library. +`strapi@alpha.12` *(expected release date: 19/03/2018)*: - [Plugin] GraphQL. diff --git a/docs/3.x.x/en/SUMMARY.md b/docs/3.x.x/en/SUMMARY.md index 3e989ef5bb..e3b077afaa 100644 --- a/docs/3.x.x/en/SUMMARY.md +++ b/docs/3.x.x/en/SUMMARY.md @@ -54,3 +54,4 @@ ### Migration * [Migrating from v1 to v3](migration/migration-guide.md) * [Migrating from 3.0.0-alpha.7.4 to 3.0.0-alpha.8](migration/migration-guide-alpha-7-4-to-alpha-8.md) +* [Migrating from 3.0.0-alpha.8 to 3.0.0-alpha.9](migration/migration-guide-alpha-8-to-alpha-9.md) diff --git a/docs/3.x.x/en/advanced/middlewares.md b/docs/3.x.x/en/advanced/middlewares.md index 787ed7a683..9adc669171 100644 --- a/docs/3.x.x/en/advanced/middlewares.md +++ b/docs/3.x.x/en/advanced/middlewares.md @@ -2,16 +2,19 @@ The middlewares are functions which are composed and executed in a stack-like manner upon request. If you are not familiar with the middleware stack in Koa, we highly recommend you to read the [Koa's documentation introduction](http://koajs.com/#introduction). +Enable the middleware in environments settings + +**Path —** [`config/environments/**`] +```json + "urlReader": { + "enabled": true + } +``` + **Path —** [`strapi/lib/middlewares/responseTime/index.js`](https://github.com/strapi/strapi/blob/master/packages/strapi/lib/middlewares/responseTime/index.js). ```js module.exports = strapi => { return { - defaults: { - responseTime: { - enabled: true - } - }, - initialize: function(cb) { strapi.app.use(async (ctx, next) => { const start = Date.now(); @@ -30,7 +33,6 @@ module.exports = strapi => { }; ``` -- `defaults` (object): Contains the defaults configurations. This object is merged to `strapi.config.middleware.settings.**`. - `initialize` (function): Called during the server boot. The callback `cb` needs to be called. Otherwise, the middleware won't be loaded into the stack. The core of Strapi embraces a small list of middlewares for performances, security and great error handling. diff --git a/docs/3.x.x/en/migration/migration-guide-alpha-8-to-alpha-9.md b/docs/3.x.x/en/migration/migration-guide-alpha-8-to-alpha-9.md new file mode 100644 index 0000000000..c24aca4120 --- /dev/null +++ b/docs/3.x.x/en/migration/migration-guide-alpha-8-to-alpha-9.md @@ -0,0 +1,71 @@ +# Migrating from 3.0.0-alpha.8 to 3.0.0-alpha.9 + +**Here are the major changes:** + +- Put roles' permissions in database +- Providers connection (Facebook, GitHub, ...) + +> Feel free to [join us on Slack](http://slack.strapi.io) and ask questions about the migration process. + + +## Getting started + +Install Strapi `alpha.9` globally on your computer. To do so run `npm install strapi@3.0.0-alpha.9 -g`. + +When it's done, generate a new empty project `strapi new myNewProject` (don't pay attention to the database configuration). + +## Configurations + +You will have to update just 2 files: `package.json` and `request.json` + +- Edit the Strapi's dependencies version: (move Strapi's dependencies to `3.0.0-alpha.9` version) in `package.json` file + +```json +{ + "dependencies": { + "lodash": "4.x.x", + "strapi": "3.0.0-alpha.9", + "strapi-mongoose": "3.0.0-alpha.9" + } +} +``` + + +- Edit the `session.enabled` settings to `true` in each environment file: `/configs/environments/***/request.json` + +```json +{ + "session": { + "enabled": true + } +} +``` + + +## Update the Admin + +Delete your old admin folder and replace it by the new one. + + +## Update the Plugins + +Copy this file `/plugins/users-permissions/config/jwt.json` **from your old project** and paste it in the corresponding one in your new project. + +Copy the fields and relations you had in your `/plugins/users-permissions/models/User.settings.json` file in the new one. + +Then, delete your old `plugins` folder and replace it by the new one. + + +## ⚠️ Roles update + +Roles are now stored in your database. You will have to re-create and configure them via the admin dashboard. + + +## ⚠️ User collection/table name has changed + +If you have an existing set of users in your database you will have to rename the collection/table from `user` to `users-permissions_user`. + +Then update all your users by changing the old role id by the new one which is in `users-permissions_role` collection/table. + + +That's all, you have now upgraded to Strapi `alpha.9`. diff --git a/package.json b/package.json index dd9e0906d2..cee89da43d 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "devDependencies": { "assert": "~1.3.0", "babel-eslint": "^6.1.2", diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index 2f8dcbc9dc..8a908acb4b 100755 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -1,6 +1,6 @@ { "name": "strapi-admin", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "Strapi Admin", "repository": { "type": "git", @@ -27,8 +27,8 @@ }, "devDependencies": { "sanitize.css": "^4.1.0", - "strapi-helper-plugin": "3.0.0-alpha.8.3", - "strapi-utils": "3.0.0-alpha.8.3" + "strapi-helper-plugin": "3.0.0-alpha.9.1", + "strapi-utils": "3.0.0-alpha.9.1" }, "author": { "name": "Strapi", diff --git a/packages/strapi-bookshelf/lib/index.js b/packages/strapi-bookshelf/lib/index.js index 29e4001013..883761975a 100755 --- a/packages/strapi-bookshelf/lib/index.js +++ b/packages/strapi-bookshelf/lib/index.js @@ -43,8 +43,6 @@ module.exports = function(strapi) { initialize: cb => { const connections = _.pickBy(strapi.config.connections, { connector: 'strapi-bookshelf' }); - const done = _.after(_.size(connections), cb); - _.forEach(connections, (connection, connectionName) => { // Apply defaults _.defaults(connection.settings, strapi.config.hook.settings.bookshelf); @@ -70,11 +68,6 @@ module.exports = function(strapi) { ORM.plugin('pagination'); } - // Select models concerned by this connection - const models = _.pickBy(strapi.models, { connection: connectionName }); - // Will call the done() method when every models will be loaded. - const loadedHook = _.after(_.size(models), done); - const mountModels = (models, target, plugin = false) => { // Parse every registered model. _.forEach(models, (definition, model) => { @@ -205,7 +198,6 @@ module.exports = function(strapi) { // Push attributes to be aware of model schema. target[model]._attributes = definition.attributes; - loadedHook(); } catch (err) { strapi.log.error('Impossible to register the `' + model + '` model.'); strapi.log.error(err); @@ -395,6 +387,8 @@ module.exports = function(strapi) { mountModels(_.pickBy(strapi.plugins[name].models, { connection: connectionName }), plugin.models, name); }); }); + + cb(); }, getQueryParams: (value, type, key) => { diff --git a/packages/strapi-bookshelf/package.json b/packages/strapi-bookshelf/package.json index 590c648289..c6cc5475b1 100755 --- a/packages/strapi-bookshelf/package.json +++ b/packages/strapi-bookshelf/package.json @@ -1,6 +1,6 @@ { "name": "strapi-bookshelf", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3", - "strapi-utils": "3.0.0-alpha.8.3" + "strapi-knex": "3.0.0-alpha.9.1", + "strapi-utils": "3.0.0-alpha.9.1" }, "strapi": { "isHook": true, diff --git a/packages/strapi-ejs/package.json b/packages/strapi-ejs/package.json index bcc43f517e..2ca76fb622 100755 --- a/packages/strapi-ejs/package.json +++ b/packages/strapi-ejs/package.json @@ -1,6 +1,6 @@ { "name": "strapi-ejs", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "EJS hook for the Strapi framework", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-admin/package.json b/packages/strapi-generate-admin/package.json index 8864226cc2..f09fd580f1 100755 --- a/packages/strapi-generate-admin/package.json +++ b/packages/strapi-generate-admin/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-admin", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3" + "strapi-admin": "3.0.0-alpha.9.1" }, "author": { "email": "hi@strapi.io", diff --git a/packages/strapi-generate-api/package.json b/packages/strapi-generate-api/package.json index a4b2a99851..af7d306043 100755 --- a/packages/strapi-generate-api/package.json +++ b/packages/strapi-generate-api/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-api", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "Generate an API for a Strapi application.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-controller/package.json b/packages/strapi-generate-controller/package.json index 1ec0a1c872..23a3c36c7a 100755 --- a/packages/strapi-generate-controller/package.json +++ b/packages/strapi-generate-controller/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-controller", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "Generate a controller for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-model/package.json b/packages/strapi-generate-model/package.json index 65cd21fb4c..f4a27a2b90 100755 --- a/packages/strapi-generate-model/package.json +++ b/packages/strapi-generate-model/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-model", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "Generate a model for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-new/lib/after.js b/packages/strapi-generate-new/lib/after.js index 7d7dd62aae..73200b3277 100755 --- a/packages/strapi-generate-new/lib/after.js +++ b/packages/strapi-generate-new/lib/after.js @@ -83,15 +83,33 @@ module.exports = (scope, cb) => { // Install default plugins and link dependencies. function pluginsInstallation() { // Define the list of default plugins. - const defaultPlugins = ['settings-manager', 'content-type-builder', 'content-manager', 'users-permissions', 'email']; + const defaultPlugins = [{ + name: 'settings-manager', + core: true + }, { + name: 'content-type-builder', + core: true + }, { + name: 'content-manager', + core: true + }, { + name: 'users-permissions', + core: true + }, { + name: 'email', + core: true + }, { + name: 'analytics', + core: false + }]; // Install each plugin. defaultPlugins.forEach(defaultPlugin => { try { - execSync(`node ${strapiBin} install ${defaultPlugin} ${scope.developerMode ? '--dev' : ''}`); - logger.info(`The plugin ${defaultPlugin} has been successfully installed.`); + execSync(`node ${strapiBin} install ${defaultPlugin.name} ${scope.developerMode && defaultPlugin.core ? '--dev' : ''}`); + logger.info(`The plugin ${defaultPlugin.name} has been successfully installed.`); } catch (error) { - logger.error(`An error occurred during ${defaultPlugin} plugin installation.`); + logger.error(`An error occurred during ${defaultPlugin.name} plugin installation.`); logger.error(error); } }); diff --git a/packages/strapi-generate-new/package.json b/packages/strapi-generate-new/package.json index 261f76f1be..0d975f63f6 100755 --- a/packages/strapi-generate-new/package.json +++ b/packages/strapi-generate-new/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-new", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3", + "strapi-utils": "3.0.0-alpha.9.1", "uuid": "^3.1.0" }, "scripts": { diff --git a/packages/strapi-generate-plugin/package.json b/packages/strapi-generate-plugin/package.json index 21250bd6ca..4c2b83267c 100755 --- a/packages/strapi-generate-plugin/package.json +++ b/packages/strapi-generate-plugin/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-plugin", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "Generate an plugin for a Strapi application.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-policy/package.json b/packages/strapi-generate-policy/package.json index 810bcfd27f..4c02f04502 100755 --- a/packages/strapi-generate-policy/package.json +++ b/packages/strapi-generate-policy/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-policy", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "Generate a policy for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-service/package.json b/packages/strapi-generate-service/package.json index f65a53c7d3..9d765d7fe3 100755 --- a/packages/strapi-generate-service/package.json +++ b/packages/strapi-generate-service/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-service", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "Generate a service for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate/package.json b/packages/strapi-generate/package.json index 4a9ec72b6a..62909337dc 100755 --- a/packages/strapi-generate/package.json +++ b/packages/strapi-generate/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3" + "strapi-utils": "3.0.0-alpha.9.1" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-helper-plugin/package.json b/packages/strapi-helper-plugin/package.json index 123d604cff..a649940d6a 100755 --- a/packages/strapi-helper-plugin/package.json +++ b/packages/strapi-helper-plugin/package.json @@ -1,6 +1,6 @@ { "name": "strapi-helper-plugin", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "Helper for Strapi plugins development", "engines": { "node": ">= 8.0.0", diff --git a/packages/strapi-knex/package.json b/packages/strapi-knex/package.json index 72f001c722..0e7a886995 100755 --- a/packages/strapi-knex/package.json +++ b/packages/strapi-knex/package.json @@ -1,6 +1,6 @@ { "name": "strapi-knex", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "Knex hook for the Strapi framework", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-middleware-views/package.json b/packages/strapi-middleware-views/package.json index 3381ee0cd2..b6383d5518 100755 --- a/packages/strapi-middleware-views/package.json +++ b/packages/strapi-middleware-views/package.json @@ -1,6 +1,6 @@ { "name": "strapi-middleware-views", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "Views hook to enable server-side rendering for the Strapi framework", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-mongoose/package.json b/packages/strapi-mongoose/package.json index b918361543..dc58c3e419 100755 --- a/packages/strapi-mongoose/package.json +++ b/packages/strapi-mongoose/package.json @@ -1,6 +1,6 @@ { "name": "strapi-mongoose", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3" + "strapi-utils": "3.0.0-alpha.9.1" }, "strapi": { "isHook": true diff --git a/packages/strapi-plugin-content-manager/package.json b/packages/strapi-plugin-content-manager/package.json index 03b141eb78..95655955d6 100755 --- a/packages/strapi-plugin-content-manager/package.json +++ b/packages/strapi-plugin-content-manager/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-content-manager", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3" + "strapi-helper-plugin": "3.0.0-alpha.9.1" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-plugin-content-type-builder/package.json b/packages/strapi-plugin-content-type-builder/package.json index bdfc43ca9d..2a50d29d0d 100755 --- a/packages/strapi-plugin-content-type-builder/package.json +++ b/packages/strapi-plugin-content-type-builder/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-content-type-builder", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3", - "strapi-generate-api": "3.0.0-alpha.8.3" + "strapi-generate": "3.0.0-alpha.9.1", + "strapi-generate-api": "3.0.0-alpha.9.1" }, "devDependencies": { - "strapi-helper-plugin": "3.0.0-alpha.8.3" + "strapi-helper-plugin": "3.0.0-alpha.9.1" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-plugin-email/package.json b/packages/strapi-plugin-email/package.json index 9e13dcac21..0078e4da10 100644 --- a/packages/strapi-plugin-email/package.json +++ b/packages/strapi-plugin-email/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-email", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3" + "strapi-helper-plugin": "3.0.0-alpha.9.1" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-plugin-settings-manager/package.json b/packages/strapi-plugin-settings-manager/package.json index cbd06820c3..afaa88527c 100755 --- a/packages/strapi-plugin-settings-manager/package.json +++ b/packages/strapi-plugin-settings-manager/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-settings-manager", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3" + "strapi-helper-plugin": "3.0.0-alpha.9.1" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-plugin-users-permissions/controllers/Auth.js b/packages/strapi-plugin-users-permissions/controllers/Auth.js index be8ca3ccc5..243ff2fa6a 100644 --- a/packages/strapi-plugin-users-permissions/controllers/Auth.js +++ b/packages/strapi-plugin-users-permissions/controllers/Auth.js @@ -70,6 +70,10 @@ module.exports = { }); } } else { + if (!_.get(strapi.plugins['users-permissions'].config.grant[provider], 'enabled')) { + return ctx.badRequest(null, 'This provider is disabled.'); + } + // Connect the user thanks to the third-party provider. let user, error; try { diff --git a/packages/strapi-plugin-users-permissions/package.json b/packages/strapi-plugin-users-permissions/package.json index 09a921ee1a..bfdb0c9341 100644 --- a/packages/strapi-plugin-users-permissions/package.json +++ b/packages/strapi-plugin-users-permissions/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-users-permissions", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3" + "strapi-helper-plugin": "3.0.0-alpha.9.1" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-plugin-users-permissions/services/Providers.js b/packages/strapi-plugin-users-permissions/services/Providers.js index 7d95c30eca..9aaaef16cd 100644 --- a/packages/strapi-plugin-users-permissions/services/Providers.js +++ b/packages/strapi-plugin-users-permissions/services/Providers.js @@ -45,35 +45,34 @@ exports.connect = (provider, query) => { } try { - const user = await strapi.query('user', 'users-permissions').findOne({email: profile.email}); + const users = await strapi.query('user', 'users-permissions').find({ + email: profile.email + }); - if (!strapi.plugins['users-permissions'].config.advanced.allow_register) { + if (_.isEmpty(_.find(users, {provider})) && !strapi.plugins['users-permissions'].config.advanced.allow_register) { return resolve([null, [{ messages: [{ id: 'Auth.advanced.allow_register' }] }], 'Register action is actualy not available.']); } - if (user && user.provider === provider) { + if (!_.isEmpty(_.find(users, {provider}))) { return resolve([user, null]); } - if (user && user.provider !== provider && strapi.plugins['users-permissions'].config.advanced.unique_email) { + if (!_.isEmpty(_.find(users, user => user.provider !== provider)) && strapi.plugins['users-permissions'].config.advanced.unique_email) { return resolve([null, [{ messages: [{ id: 'Auth.form.error.email.taken' }] }], 'Email is already taken.']); } - if (!user || _.get(user, 'provider') !== provider) { - // Retrieve role `guest`. - const guest = await strapi.query('role', 'users-permissions').findOne({ type: 'guest' }, []); + // Retrieve role `guest`. + const guest = await strapi.query('role', 'users-permissions').findOne({ type: 'guest' }, []); - // Create the new user. - const params = _.assign(profile, { - provider: provider, - role: guest._id || guest.id - }); + // Create the new user. + const params = _.assign(profile, { + provider: provider, + role: guest._id || guest.id + }); - const createdUser = await strapi.query('user', 'users-permissions').create(params); + const createdUser = await strapi.query('user', 'users-permissions').create(params); - return resolve([createdUser, null]); - } - resolve([user, null]); + return resolve([createdUser, null]); } catch (err) { reject([null, err]); } diff --git a/packages/strapi-redis/package.json b/packages/strapi-redis/package.json index 4081698a66..6fb22c9f7a 100755 --- a/packages/strapi-redis/package.json +++ b/packages/strapi-redis/package.json @@ -1,6 +1,6 @@ { "name": "strapi-redis", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3" + "strapi-utils": "3.0.0-alpha.9.1" }, "strapi": { "isHook": true diff --git a/packages/strapi-utils/package.json b/packages/strapi-utils/package.json index c6440f409b..834b90ec9e 100755 --- a/packages/strapi-utils/package.json +++ b/packages/strapi-utils/package.json @@ -1,6 +1,6 @@ { "name": "strapi-utils", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "description": "Shared utilities for the Strapi packages", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi/package.json b/packages/strapi/package.json index e14701564b..9a3ec1e728 100755 --- a/packages/strapi/package.json +++ b/packages/strapi/package.json @@ -1,6 +1,6 @@ { "name": "strapi", - "version": "3.0.0-alpha.8.3", + "version": "3.0.0-alpha.9.1", "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.8.3", - "strapi-generate-admin": "3.0.0-alpha.8.3", - "strapi-generate-api": "3.0.0-alpha.8.3", - "strapi-generate-new": "3.0.0-alpha.8.3", - "strapi-generate-plugin": "3.0.0-alpha.8.3", - "strapi-generate-policy": "3.0.0-alpha.8.3", - "strapi-generate-service": "3.0.0-alpha.8.3", - "strapi-utils": "3.0.0-alpha.8.3" + "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" }, "author": { "email": "hi@strapi.io",