From 1278befc5f5507238ea5df619e18a0522ed66b4f Mon Sep 17 00:00:00 2001 From: Yuliya Pazniak Date: Tue, 12 Nov 2024 14:15:32 +0300 Subject: [PATCH 1/2] add description how to reset user password --- datapress/administration/disable-user.md | 52 +++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/datapress/administration/disable-user.md b/datapress/administration/disable-user.md index c3554e0..4ec5c06 100644 --- a/datapress/administration/disable-user.md +++ b/datapress/administration/disable-user.md @@ -152,4 +152,54 @@ Add **icds_order_header=1** in your request URL: https://{your-wordpress-site}/wp-json/wp/v2/users?context=edit&icds_order_header=1 ``` -Also use the **X-Icds-Order** header. Here you can specify the field name to sort users, for, example **url** or **username**. \ No newline at end of file +Also use the **X-Icds-Order** header. Here you can specify the field name to sort users, for, example **url** or **username**. + +## How to reset user password + +To reset a user password, you need to send a **POST** request to the following URL: + +``` +https://{your-wordpress-site}/wp-json/integration-cds/v1/reset_password?email={userEmail}&id={userId}&login={userLogin} +``` + +This request should contain one of the following parameters: + +- **email**: User email +- **id**: WordPress user ID +- **login**: User login for the WordPress site + +The order of reading parameters is: id, email, login. + +This request will immediately send a password reset link to the specified user email and return an empty body (204 response). In case of an error, it will return a 500 response with an error description: + +```text +{ + "code": 3, + "message": "User not found.", + "data": null +} +``` + +Alternatively, you can send a **GET** request to: + +``` +https://{your-wordpress-site}/wp-json/integration-cds/v1/reset_password_link?email=user@example.com +``` + +This request should contain **one** of the following parameters: + +- **email**: User email +- **id**: WordPress user ID +- **login**: User login for the WordPress site + +It will return a JSON response with the link for password resetting created by WordPress (or an error description in case of an error): + +```text +{ + "link": "https://your-wordpress-site.com/wp-login.php?action=rp&key=HEA7wLLCEvtnV3Ick1bQ&login={username}&wp_lang=en_US" +} +``` + +:::note +Don’t forget to include Basic Authentication for all requests. +::: \ No newline at end of file From 72fc8404118a6560f41faeee2fa08e0ff8098da8 Mon Sep 17 00:00:00 2001 From: George Doubinski Date: Wed, 13 Nov 2024 12:57:39 +1100 Subject: [PATCH 2/2] Fixed API description --- datapress/administration/disable-user.md | 173 ++++++++++++----------- 1 file changed, 90 insertions(+), 83 deletions(-) diff --git a/datapress/administration/disable-user.md b/datapress/administration/disable-user.md index 4ec5c06..7b7f049 100644 --- a/datapress/administration/disable-user.md +++ b/datapress/administration/disable-user.md @@ -49,32 +49,38 @@ https://{url}/wp-json/wp/v2/users/{id} Pay attention to the meta fields in the response. -```twig +```json "meta": { "persisted_preferences": { - "core/edit-post": { - "isComplementaryAreaVisible": true, - "welcomeGuide": false, - "openPanels": [ - "post-status", - "page-attributes", - "featured-image" -] -}, -"_modified": "2024-03-09T08:18:09.934Z" -}, + "core/edit-post": { + "isComplementaryAreaVisible": true, + "welcomeGuide": false, + "openPanels": [ + "post-status", + "page-attributes", + "featured-image" + ] + }, + "_modified": "2024-03-09T08:18:09.934Z" + }, "icds_binding": 3, "icds_timezone": "+00:00", "icds_locale": "en_US", "icds_disabled": 0, "icds_last_login": "2024-03-20T08:30:14+00:00", - "icds_meta": "{"icds_binding":3,"icds_locale":"en_US","icds_timezone":"+00:00","icds_disabled":0,"icds_last_login":"2023-03-20T08:30:14+00:00"}", + "icds_meta": { + "icds_binding": 3, + "icds_locale": "en_US", + "icds_timezone": "+00:00", + "icds_disabled": 0, + "icds_last_login": "2023-03-20T08:30:14+00:00" + }, "icds_binding_ref": { "Name": "Chaunce Perrie", "Id": "4fc12b21-686a-ed11-81ac-00224892b4a1", "LogicalName": "contact", "KeyAttributes": null -} + } } ``` @@ -84,18 +90,18 @@ The **icds_last_login** field shows the last login date. It can be empty if the To get users filtered by conditions, send a GET request with the following encoded part: -```text +```json [ -{ -"Field": "icds_binding", -"Operator": "eq", -"Value": "1" -}, -{ -"Field": "icds_binding_ref", -"Operator": "ne", -"Value": null -} + { + "Field": "icds_binding", + "Operator": "eq", + "Value": "1" + }, + { + "Field": "icds_binding_ref", + "Operator": "ne", + "Value": null + } ] ``` @@ -111,18 +117,18 @@ Then add this encoded part in the URL. See the example below: Another way to filter users is to use the **X-Icds-Filter** header. The value of the header can be: -```text +```json [ -{ -"Field": "icds_binding", -"Operator": "eq", -"Value": "1" -}, -{ -"Field": "icds_binding_ref", -"Operator": "ne", -"Value": null -} + { + "Field": "icds_binding", + "Operator": "eq", + "Value": "1" + }, + { + "Field": "icds_binding_ref", + "Operator": "ne", + "Value": null + } ] ``` In this example, you should not encode this text. @@ -154,52 +160,53 @@ https://{your-wordpress-site}/wp-json/wp/v2/users?context=edit&icds_order_header Also use the **X-Icds-Order** header. Here you can specify the field name to sort users, for, example **url** or **username**. -## How to reset user password - -To reset a user password, you need to send a **POST** request to the following URL: - -``` -https://{your-wordpress-site}/wp-json/integration-cds/v1/reset_password?email={userEmail}&id={userId}&login={userLogin} -``` - -This request should contain one of the following parameters: - -- **email**: User email -- **id**: WordPress user ID -- **login**: User login for the WordPress site - -The order of reading parameters is: id, email, login. - -This request will immediately send a password reset link to the specified user email and return an empty body (204 response). In case of an error, it will return a 500 response with an error description: - -```text -{ - "code": 3, - "message": "User not found.", - "data": null -} -``` - -Alternatively, you can send a **GET** request to: - -``` -https://{your-wordpress-site}/wp-json/integration-cds/v1/reset_password_link?email=user@example.com -``` - -This request should contain **one** of the following parameters: - -- **email**: User email -- **id**: WordPress user ID -- **login**: User login for the WordPress site - -It will return a JSON response with the link for password resetting created by WordPress (or an error description in case of an error): - -```text -{ - "link": "https://your-wordpress-site.com/wp-login.php?action=rp&key=HEA7wLLCEvtnV3Ick1bQ&login={username}&wp_lang=en_US" -} -``` +## How to send a password reset message :::note -Don’t forget to include Basic Authentication for all requests. -::: \ No newline at end of file +All API requests below require Basic Authentication. +::: + +To send a password reset message to a user, you can use one of the following: + +1. Send a password reset email using WordPress. Send a **POST** request to: + + ``` + https://{your-wordpress-site}/wp-json/integration-cds/v1/reset_password?email={userEmail}&id={userId}&login={userLogin} + ``` + + To identify the user, the request should contain **one** of the following parameters: + + - **id**: WordPress user ID + - **email**: User email + - **login**: User login for the WordPress site + + The parameters priority is: id, email, login. + + This request will send a password reset link to the user and return an empty body (204 response). In case of an error, it will return a 500 response with the error description: + + ```json + { + "code": 3, + "message": "User not found.", + "data": null + } + ``` +2. Generate a password reset link. Send a **GET** request to: + + ``` + https://{your-wordpress-site}/wp-json/integration-cds/v1/reset_password_link?email=user@example.com + ``` + + To identify the user, the request should contain **one** of the following parameters: + + - **id**: WordPress user ID + - **email**: User email + - **login**: User login for the WordPress site + + It will return a JSON response with a password reset link or an error description in case of an error: + + ```json + { + "link": "https://your-wordpress-site.com/wp-login.php?action=rp&key=HEA7wLLCEvtnV3Ick1bQ&login={username}&wp_lang=en_US" + } + ```