Merge pull request #5655 from ScottAgirs/patch---adjust-naming-to-password-mutations

Fix #5653: improve UserPermissions - password mutations
This commit is contained in:
Alexandre BODIN 2020-05-25 15:44:48 +02:00 committed by GitHub
commit f32bc7b30b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 17 deletions

View File

@ -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.

View File

@ -72,7 +72,7 @@
{
"method": "POST",
"path": "/auth/reset-password",
"handler": "Auth.changePassword"
"handler": "Auth.resetPassword"
},
{
"method": "GET",

View File

@ -199,7 +199,7 @@ module.exports = {
}
},
async changePassword(ctx) {
async resetPassword(ctx) {
const { password, passwordConfirmation, code } = {
...ctx.request.body,
...ctx.params,

View File

@ -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"

View File

@ -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);

View File

@ -174,8 +174,8 @@ module.exports = {
});
}
},
async changePassword(ctx) {
async resetPassword(ctx) {
const params = _.assign({}, ctx.request.body, ctx.params);
if (