diff --git a/docs/3.0.0-beta.x/plugins/users-permissions.md b/docs/3.0.0-beta.x/plugins/users-permissions.md index f8ae3aad86..f3b4bded42 100644 --- a/docs/3.0.0-beta.x/plugins/users-permissions.md +++ b/docs/3.0.0-beta.x/plugins/users-permissions.md @@ -510,14 +510,15 @@ axios }); ``` -This action will send the user an email that contains a URL with the needed code for the [reset password](#password-reset). +This action will send the user an email that contains a URL with the needed code for the [reset password](#reset-password). The URL must link to your reset password form in your frontend application. To configure it you will have to go in the Roles & Permissions settings and navigate to the Advanced Settings tab. -### Password reset +### Reset Password This action will reset the user password. +Also works with the [GraphQL Plugin](https://strapi.io/documentation/3.0.0-beta.x/plugins/graphql.html), exposes `resetPassword` mutation. #### Usage @@ -535,7 +536,7 @@ axios }) .then(response => { // Handle success. - console.log("Your user's password has been changed."); + console.log("Your user's password has been reset."); }) .catch(error => { // Handle error. @@ -543,6 +544,8 @@ axios }); ``` + + ### Email validation This action sends an email to the user with the link to confirm the user. diff --git a/packages/strapi-admin/config/routes.json b/packages/strapi-admin/config/routes.json index 686239cde3..9963242794 100644 --- a/packages/strapi-admin/config/routes.json +++ b/packages/strapi-admin/config/routes.json @@ -72,7 +72,7 @@ { "method": "POST", "path": "/auth/reset-password", - "handler": "Auth.changePassword" + "handler": "Auth.resetPassword" }, { "method": "GET", diff --git a/packages/strapi-admin/controllers/Auth.js b/packages/strapi-admin/controllers/Auth.js index 9117478336..221e0c42b6 100644 --- a/packages/strapi-admin/controllers/Auth.js +++ b/packages/strapi-admin/controllers/Auth.js @@ -199,7 +199,7 @@ module.exports = { } }, - async changePassword(ctx) { + async resetPassword(ctx) { const { password, passwordConfirmation, code } = { ...ctx.request.body, ...ctx.params, diff --git a/packages/strapi-plugin-users-permissions/config/routes.json b/packages/strapi-plugin-users-permissions/config/routes.json index 5b917339c9..d9de765de5 100644 --- a/packages/strapi-plugin-users-permissions/config/routes.json +++ b/packages/strapi-plugin-users-permissions/config/routes.json @@ -260,11 +260,11 @@ { "method": "POST", "path": "/auth/reset-password", - "handler": "Auth.changePassword", + "handler": "Auth.resetPassword", "config": { "policies": ["plugins::users-permissions.ratelimit"], "prefix": "", - "description": "Change a user's password", + "description": "Reset user password with a code (resetToken)", "tag": { "plugin": "users-permissions", "name": "User" diff --git a/packages/strapi-plugin-users-permissions/config/schema.graphql.js b/packages/strapi-plugin-users-permissions/config/schema.graphql.js index 96a444e283..64f1172661 100644 --- a/packages/strapi-plugin-users-permissions/config/schema.graphql.js +++ b/packages/strapi-plugin-users-permissions/config/schema.graphql.js @@ -53,8 +53,8 @@ module.exports = { user: UsersPermissionsMe! } - type ForgotPassword { - ok: Boolean + type UserPersmissionsPasswordPayload { + ok: Boolean! } `, query: ` @@ -63,8 +63,8 @@ module.exports = { mutation: ` login(input: UsersPermissionsLoginInput!): UsersPermissionsLoginPayload! register(input: UsersPermissionsRegisterInput!): UsersPermissionsLoginPayload! - forgotPassword(email: String!): ForgotPassword - changePassword(password: String!, passwordConfirmation: String!, code: String!): UsersPermissionsLoginPayload + forgotPassword(email: String!): UserPersmissionsPasswordPayload + resetPassword(password: String!, passwordConfirmation: String!, code: String!): UsersPermissionsLoginPayload emailConfirmation(confirmation: String!): UsersPermissionsLoginPayload `, resolver: { @@ -235,13 +235,13 @@ module.exports = { }; }, }, - changePassword: { - description: 'Change your password based on a code', - resolverOf: 'plugins::users-permissions.auth.changePassword', + resetPassword: { + description: 'Reset user password. Confirm with a code (resetToken from forgotPassword)', + resolverOf: 'plugins::users-permissions.auth.resetPassword', resolver: async (obj, options, { context }) => { context.request.body = _.toPlainObject(options); - await strapi.plugins['users-permissions'].controllers.auth.changePassword(context); + await strapi.plugins['users-permissions'].controllers.auth.resetPassword(context); let output = context.body.toJSON ? context.body.toJSON() : context.body; checkBadRequest(output); diff --git a/packages/strapi-plugin-users-permissions/controllers/Auth.js b/packages/strapi-plugin-users-permissions/controllers/Auth.js index 851bbbf6bd..3a0e9100d9 100644 --- a/packages/strapi-plugin-users-permissions/controllers/Auth.js +++ b/packages/strapi-plugin-users-permissions/controllers/Auth.js @@ -174,8 +174,8 @@ module.exports = { }); } }, - - async changePassword(ctx) { + + async resetPassword(ctx) { const params = _.assign({}, ctx.request.body, ctx.params); if (