You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -288,10 +289,12 @@ The following is a list of the symbols you can provide to the `operations`, `ski
288
289
:login
289
290
:logout
290
291
:sign_up
291
-
:update_password
292
-
:send_password_reset
293
292
:confirm_account
293
+
:send_password_reset
294
294
:check_password_token
295
+
:update_password
296
+
:send_password_reset_with_token
297
+
:update_password_with_token
295
298
```
296
299
297
300
### Configuring Model
@@ -458,9 +461,11 @@ Operation | Description | Example
458
461
login | This mutation has a second field by default. `credentials` can be fetched directly on the mutation return type.<br>Credentials are still returned in the headers of the response. | userLogin(email: String!, password: String!): UserLoginPayload
459
462
logout | | userLogout: UserLogoutPayload
460
463
signUp | The parameter `confirmSuccessUrl` is optional unless you are using the `confirmable` plugin from Devise in your `resource`'s model. If you have `confirmable` set up, you will have to provide it unless you have `config.default_confirm_success_url` set in `config/initializers/devise_token_auth.rb`. | userSignUp(email: String!, password: String!, passwordConfirmation: String!, confirmSuccessUrl: String): UserSignUpPayload
updatePassword | The parameter `currentPassword` is optional if you have `config.check_current_password_before_update` set to false (disabled by default) on your generated `config/initializers/devise_token_aut.rb` or if the `resource` model supports the `recoverable` Devise plugin and the `resource`'s `allow_password_change` attribute is set to true (this is done in the `userCheckPasswordToken` query when you click on the sent email's link). | userUpdatePassword(password: String!, passwordConfirmation: String!, currentPassword: String): UserUpdatePasswordPayload
464
+
sendResetPassword | Sends an email to the provided address with a link to reset the password of the resource. **This mutation is part of the first and soon to be deprecated password reset flow.**| userSendResetPassword(email: String!, redirectUrl: String!): UserSendReserPasswordPayload
465
+
updatePassword | The parameter `currentPassword` is optional if you have `config.check_current_password_before_update` set to false (disabled by default) on your generated `config/initializers/devise_token_aut.rb` or if the `resource` model supports the `recoverable` Devise plugin and the `resource`'s `allow_password_change` attribute is set to true (this is done in the `userCheckPasswordToken` query when you click on the sent email's link). **This mutation is part of the first and soon to be deprecated password reset flow.**| userUpdatePassword(password: String!, passwordConfirmation: String!, currentPassword: String): UserUpdatePasswordPayload
463
466
resendConfirmation | The `UserResendConfirmationPayload` will return the `authenticatable` resource that was sent the confirmation instructions but also has a `message: String!` that can be used to notify a user what to do after the instructions were sent to them | userResendConfirmation(email: String!, redirectUrl: String!): UserResendConfirmationPayload
467
+
userSendPasswordResetWithToken | Sends an email to the provided address with a link to reset the password of the resource. First step of the most recently implemented password reset flow. | userSendPasswordResetWithToken(email: String!, redirectUrl: String!): UserSendPasswordResetWithTokenPayload
468
+
userUpdatePasswordWithToken | Uses a `resetPasswordToken` to update the password of a resource. Second and last step of the most recently implemented password reset flow. | userSendPasswordResetWithToken(resetPasswordToken: String!, password: String!, passwordConfirmation: String!): UserUpdatePasswordWithTokenPayload
464
469
465
470
#### Queries
466
471
Operation | Description | Example
@@ -478,6 +483,11 @@ you can use [our specs](spec/requests) to better understand how to use the gem.
478
483
Also, the [dummy app](spec/dummy) used in our specs will give you
479
484
a clear idea on how to configure the gem on your Rails application.
480
485
486
+
### Reset Password Flow
487
+
This gem supports two password recovery flows. The most recently implemented is preferred and
488
+
requires less steps. More detail on how it works can be found
489
+
[here](docs/usage/reset_password_flow.md).
490
+
481
491
### More Configuration Options
482
492
As mentioned in the introduction there are many configurations that will change how this gem behaves. You can change
483
493
this values on the initializer files generated by the installer.
This gem supports two different ways to reset a password on a resource. Each password reset flow has it's own set of
3
+
operations and this document will explain in more detail how to use each.
4
+
The first and most recently implemented flow is preferred as it requires less steps and doesn't require a mutation
5
+
to return a redirect on the response. Flow 2 might be deprecated in the future.
6
+
7
+
## Flow #1 (Preferred)
8
+
This flow only has two steps. Each step name refers to the operation name you can use in the mount options to skip or override.
9
+
10
+
### 1. send_password_reset_with_token
11
+
This operation on the gem will send an email to the specified address if it's found on the system. Returns an error if the email is not found. Here's an example assuming the resource used
The email will contain a link to the `redirectUrl` (https://google.com in the example) and append a `reset_password_token` query param. This is the token you will
24
+
need to use in the next step in order to reset the password.
25
+
26
+
### 2. update_password_with_token
27
+
This mutation uses the token sent on the email to find the resource you are trying to recover.
28
+
All you have to do is send a valid token together with the new password and password confirmation.
29
+
Here's an example assuming the resource used for authentication is `User`:
30
+
31
+
```graphql
32
+
mutation {
33
+
userUpdatePasswordWithToken(
34
+
resetPasswordToken: "token_here",
35
+
password: "password123",
36
+
passwordConfirmation: "password123"
37
+
) {
38
+
authenticatable { email }
39
+
credentials { accessToken }
40
+
}
41
+
}
42
+
```
43
+
The mutation has two fields:
44
+
1.`authenticatable`: Just like other mutations, returns the actual resource you just recover the password for.
45
+
1.`credentials`: This is a nullable field. It will only return credentials as if you had just logged
46
+
in into the app if you explicitly say so by overriding the mutation. The docs have more detail
47
+
on how to extend the default behavior of mutations, but
0 commit comments