mirror of
https://github.com/strapi/strapi.git
synced 2025-10-17 02:53:22 +00:00
Merge pull request #5655 from ScottAgirs/patch---adjust-naming-to-password-mutations
Fix #5653: improve UserPermissions - password mutations
This commit is contained in:
commit
f32bc7b30b
@ -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.
|
||||
|
@ -72,7 +72,7 @@
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/auth/reset-password",
|
||||
"handler": "Auth.changePassword"
|
||||
"handler": "Auth.resetPassword"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
|
@ -199,7 +199,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
async changePassword(ctx) {
|
||||
async resetPassword(ctx) {
|
||||
const { password, passwordConfirmation, code } = {
|
||||
...ctx.request.body,
|
||||
...ctx.params,
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
|
@ -174,8 +174,8 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async changePassword(ctx) {
|
||||
|
||||
async resetPassword(ctx) {
|
||||
const params = _.assign({}, ctx.request.body, ctx.params);
|
||||
|
||||
if (
|
||||
|
Loading…
x
Reference in New Issue
Block a user