mirror of
https://github.com/strapi/strapi.git
synced 2025-10-19 12:02:38 +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.
|
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.
|
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.
|
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
|
#### Usage
|
||||||
|
|
||||||
@ -535,7 +536,7 @@ axios
|
|||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
// Handle success.
|
// Handle success.
|
||||||
console.log("Your user's password has been changed.");
|
console.log("Your user's password has been reset.");
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// Handle error.
|
// Handle error.
|
||||||
@ -543,6 +544,8 @@ axios
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Email validation
|
### Email validation
|
||||||
|
|
||||||
This action sends an email to the user with the link to confirm the user.
|
This action sends an email to the user with the link to confirm the user.
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
{
|
{
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"path": "/auth/reset-password",
|
"path": "/auth/reset-password",
|
||||||
"handler": "Auth.changePassword"
|
"handler": "Auth.resetPassword"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
|
@ -199,7 +199,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async changePassword(ctx) {
|
async resetPassword(ctx) {
|
||||||
const { password, passwordConfirmation, code } = {
|
const { password, passwordConfirmation, code } = {
|
||||||
...ctx.request.body,
|
...ctx.request.body,
|
||||||
...ctx.params,
|
...ctx.params,
|
||||||
|
@ -260,11 +260,11 @@
|
|||||||
{
|
{
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"path": "/auth/reset-password",
|
"path": "/auth/reset-password",
|
||||||
"handler": "Auth.changePassword",
|
"handler": "Auth.resetPassword",
|
||||||
"config": {
|
"config": {
|
||||||
"policies": ["plugins::users-permissions.ratelimit"],
|
"policies": ["plugins::users-permissions.ratelimit"],
|
||||||
"prefix": "",
|
"prefix": "",
|
||||||
"description": "Change a user's password",
|
"description": "Reset user password with a code (resetToken)",
|
||||||
"tag": {
|
"tag": {
|
||||||
"plugin": "users-permissions",
|
"plugin": "users-permissions",
|
||||||
"name": "User"
|
"name": "User"
|
||||||
|
@ -53,8 +53,8 @@ module.exports = {
|
|||||||
user: UsersPermissionsMe!
|
user: UsersPermissionsMe!
|
||||||
}
|
}
|
||||||
|
|
||||||
type ForgotPassword {
|
type UserPersmissionsPasswordPayload {
|
||||||
ok: Boolean
|
ok: Boolean!
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
query: `
|
query: `
|
||||||
@ -63,8 +63,8 @@ module.exports = {
|
|||||||
mutation: `
|
mutation: `
|
||||||
login(input: UsersPermissionsLoginInput!): UsersPermissionsLoginPayload!
|
login(input: UsersPermissionsLoginInput!): UsersPermissionsLoginPayload!
|
||||||
register(input: UsersPermissionsRegisterInput!): UsersPermissionsLoginPayload!
|
register(input: UsersPermissionsRegisterInput!): UsersPermissionsLoginPayload!
|
||||||
forgotPassword(email: String!): ForgotPassword
|
forgotPassword(email: String!): UserPersmissionsPasswordPayload
|
||||||
changePassword(password: String!, passwordConfirmation: String!, code: String!): UsersPermissionsLoginPayload
|
resetPassword(password: String!, passwordConfirmation: String!, code: String!): UsersPermissionsLoginPayload
|
||||||
emailConfirmation(confirmation: String!): UsersPermissionsLoginPayload
|
emailConfirmation(confirmation: String!): UsersPermissionsLoginPayload
|
||||||
`,
|
`,
|
||||||
resolver: {
|
resolver: {
|
||||||
@ -235,13 +235,13 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
changePassword: {
|
resetPassword: {
|
||||||
description: 'Change your password based on a code',
|
description: 'Reset user password. Confirm with a code (resetToken from forgotPassword)',
|
||||||
resolverOf: 'plugins::users-permissions.auth.changePassword',
|
resolverOf: 'plugins::users-permissions.auth.resetPassword',
|
||||||
resolver: async (obj, options, { context }) => {
|
resolver: async (obj, options, { context }) => {
|
||||||
context.request.body = _.toPlainObject(options);
|
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;
|
let output = context.body.toJSON ? context.body.toJSON() : context.body;
|
||||||
|
|
||||||
checkBadRequest(output);
|
checkBadRequest(output);
|
||||||
|
@ -175,7 +175,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async changePassword(ctx) {
|
async resetPassword(ctx) {
|
||||||
const params = _.assign({}, ctx.request.body, ctx.params);
|
const params = _.assign({}, ctx.request.body, ctx.params);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user