diff --git a/CHANGELOG.md b/CHANGELOG.md index d5a323c..b122126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 17.3.0 + +* Deprecate `createVerification` method in `Account` service +* Add `createEmailVerification` method in `Account` service + ## 15.1.0 * Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service diff --git a/docs/account.md b/docs/account.md index 5f6cc02..4007dd3 100644 --- a/docs/account.md +++ b/docs/account.md @@ -580,7 +580,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about ```http request -POST https://cloud.appwrite.io/v1/account/verification +POST https://cloud.appwrite.io/v1/account/verifications/email ``` ** Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. @@ -596,7 +596,37 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ ```http request -PUT https://cloud.appwrite.io/v1/account/verification +POST https://cloud.appwrite.io/v1/account/verifications/email +``` + +** Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. + +Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| url | string | URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | | + + +```http request +PUT https://cloud.appwrite.io/v1/account/verifications/email +``` + +** Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | User ID. | | +| secret | string | Valid verification token. | | + + +```http request +PUT https://cloud.appwrite.io/v1/account/verifications/email ``` ** Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. ** @@ -610,14 +640,14 @@ PUT https://cloud.appwrite.io/v1/account/verification ```http request -POST https://cloud.appwrite.io/v1/account/verification/phone +POST https://cloud.appwrite.io/v1/account/verifications/phone ``` ** Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. ** ```http request -PUT https://cloud.appwrite.io/v1/account/verification/phone +PUT https://cloud.appwrite.io/v1/account/verifications/phone ``` ** Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. ** diff --git a/docs/examples/account/create-email-verification.md b/docs/examples/account/create-email-verification.md new file mode 100644 index 0000000..691d6fa --- /dev/null +++ b/docs/examples/account/create-email-verification.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$account = new Account($client); + +$result = $account->createEmailVerification( + url: 'https://example.com' +); \ No newline at end of file diff --git a/docs/examples/account/update-email-verification.md b/docs/examples/account/update-email-verification.md new file mode 100644 index 0000000..95cd1b5 --- /dev/null +++ b/docs/examples/account/update-email-verification.md @@ -0,0 +1,16 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$account = new Account($client); + +$result = $account->updateEmailVerification( + userId: '', + secret: '' +); \ No newline at end of file diff --git a/docs/functions.md b/docs/functions.md index ff64822..a122c03 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -186,7 +186,7 @@ POST https://cloud.appwrite.io/v1/functions/{functionId}/deployments/template ** Create a deployment based on a template. -Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details. ** +Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details. ** ### Parameters diff --git a/docs/sites.md b/docs/sites.md index 71ef1a0..cf9fc74 100644 --- a/docs/sites.md +++ b/docs/sites.md @@ -182,7 +182,7 @@ POST https://cloud.appwrite.io/v1/sites/{siteId}/deployments/template ** Create a deployment based on a template. -Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to find the template details. ** +Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details. ** ### Parameters diff --git a/docs/tablesdb.md b/docs/tablesdb.md index 28b154e..62d20c0 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -91,7 +91,7 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables ``` -** Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. ** +** Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. ** ### Parameters @@ -178,7 +178,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | Column Key. | | | required | boolean | Is column required? | | | default | boolean | Default value for column when not provided. Cannot be set when column is required. | | @@ -196,7 +196,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | **Required** Column Key. | | | required | boolean | Is column required? | | | default | boolean | Default value for column when not provided. Cannot be set when column is required. | | @@ -449,7 +449,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | Column Key. | | | required | boolean | Is column required? | | | default | array | Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. | | @@ -466,7 +466,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | **Required** Column Key. | | | required | boolean | Is column required? | | | default | array | Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. | | @@ -484,7 +484,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | Column Key. | | | required | boolean | Is column required? | | | default | array | Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. | | @@ -501,7 +501,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | **Required** Column Key. | | | required | boolean | Is column required? | | | default | array | Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. | | @@ -519,7 +519,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | Column Key. | | | required | boolean | Is column required? | | | default | array | Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. | | @@ -536,7 +536,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | **Required** Column Key. | | | required | boolean | Is column required? | | | default | array | Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. | | @@ -576,7 +576,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | Column Key. | | | size | integer | Column size for text columns, in number of characters. | | | required | boolean | Is column required? | | @@ -597,7 +597,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | **Required** Column Key. | | | required | boolean | Is column required? | | | default | string | Default value for column when not provided. Cannot be set when column is required. | | @@ -702,7 +702,7 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, status, attributes, error | [] | @@ -718,7 +718,7 @@ Type can be `key`, `fulltext`, or `unique`. ** | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | Index Key. | | | type | string | Index type. | | | columns | array | Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. | | @@ -737,7 +737,7 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes/ | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | **Required** Index Key. | | @@ -752,7 +752,7 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/index | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | key | string | **Required** Index Key. | | @@ -767,7 +767,7 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). | | | queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | @@ -775,14 +775,14 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows ``` -** Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. ** +** Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. ** ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. | | | rowId | string | Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | | data | object | Row data as JSON object. | {} | | permissions | array | An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | @@ -792,14 +792,14 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows ``` -** Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. ** +** Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. ** ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. | | | rows | array | Array of rows data as JSON objects. | [] | @@ -807,7 +807,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows PUT https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows ``` -** Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. +** Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. ** ### Parameters @@ -846,7 +846,7 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | @@ -861,7 +861,7 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{ro | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | rowId | string | **Required** Row ID. | | | queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | @@ -870,7 +870,7 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{ro PUT https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId} ``` -** Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. ** +** Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. ** ### Parameters @@ -911,7 +911,7 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows/ | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | | rowId | string | **Required** Row ID. | | diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 69c0a1f..2c89cc5 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,11 +37,11 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/17.2.0 ()', + 'user-agent' => 'AppwritePHPSDK/17.3.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '17.2.0', + 'x-sdk-version'=> '17.3.0', ]; /** diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 76b8bd5..23f1b08 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -1664,12 +1664,58 @@ public function createPhoneToken(string $userId, string $phone): array * @throws AppwriteException * @return array */ + public function createEmailVerification(string $url): array + { + $apiPath = str_replace( + [], + [], + '/account/verifications/email' + ); + + $apiParams = []; + $apiParams['url'] = $url; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Use this endpoint to send a verification message to your user email address + * to confirm they are the valid owners of that address. Both the **userId** + * and **secret** arguments will be passed as query parameters to the URL you + * have provided to be attached to the verification email. The provided URL + * should redirect the user back to your app and allow you to complete the + * verification process by verifying both the **userId** and **secret** + * parameters. Learn more about how to [complete the verification + * process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). + * The verification link sent to the user's email address is valid for 7 days. + * + * Please note that in order to avoid a [Redirect + * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), + * the only valid redirect URLs are the ones from domains you have set when + * adding your platforms in the console interface. + * + * + * @param string $url + * @throws AppwriteException + * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createEmailVerification` instead. + * @see Account::createEmailVerification + */ public function createVerification(string $url): array { $apiPath = str_replace( [], [], - '/account/verification' + '/account/verifications/email' ); $apiParams = []; @@ -1697,12 +1743,49 @@ public function createVerification(string $url): array * @throws AppwriteException * @return array */ + public function updateEmailVerification(string $userId, string $secret): array + { + $apiPath = str_replace( + [], + [], + '/account/verifications/email' + ); + + $apiParams = []; + $apiParams['userId'] = $userId; + $apiParams['secret'] = $secret; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Use this endpoint to complete the user email verification process. Use both + * the **userId** and **secret** parameters that were attached to your app URL + * to verify the user email ownership. If confirmed this route will return a + * 200 status code. + * + * @param string $userId + * @param string $secret + * @throws AppwriteException + * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateEmailVerification` instead. + * @see Account::updateEmailVerification + */ public function updateVerification(string $userId, string $secret): array { $apiPath = str_replace( [], [], - '/account/verification' + '/account/verifications/email' ); $apiParams = []; @@ -1738,7 +1821,7 @@ public function createPhoneVerification(): array $apiPath = str_replace( [], [], - '/account/verification/phone' + '/account/verifications/phone' ); $apiParams = []; @@ -1770,7 +1853,7 @@ public function updatePhoneVerification(string $userId, string $secret): array $apiPath = str_replace( [], [], - '/account/verification/phone' + '/account/verifications/phone' ); $apiParams = []; diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index 1f335c1..a8fb292 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -615,7 +615,7 @@ public function createDuplicateDeployment(string $functionId, string $deployment * Create a deployment based on a template. * * Use this endpoint with combination of - * [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to + * [listTemplates](https://appwrite.io/docs/products/functions/templates) to * find the template details. * * @param string $functionId diff --git a/src/Appwrite/Services/Sites.php b/src/Appwrite/Services/Sites.php index 698e684..3052c2a 100644 --- a/src/Appwrite/Services/Sites.php +++ b/src/Appwrite/Services/Sites.php @@ -604,8 +604,8 @@ public function createDuplicateDeployment(string $siteId, string $deploymentId): * Create a deployment based on a template. * * Use this endpoint with combination of - * [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to - * find the template details. + * [listTemplates](https://appwrite.io/docs/products/sites/templates) to find + * the template details. * * @param string $siteId * @param string $repository diff --git a/src/Appwrite/Services/TablesDb.php b/src/Appwrite/Services/TablesDb.php index 0258f25..9d594a0 100644 --- a/src/Appwrite/Services/TablesDb.php +++ b/src/Appwrite/Services/TablesDb.php @@ -228,7 +228,7 @@ public function listTables(string $databaseId, ?array $queries = null, ?string $ /** * Create a new Table. Before using this route, you should create a new * database resource using either a [server - * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) * API or directly from your database console. * * @param string $databaseId @@ -1882,7 +1882,7 @@ public function listRows(string $databaseId, string $tableId, ?array $queries = /** * Create a new Row. Before using this route, you should create a new table * resource using either a [server - * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) * API or directly from your database console. * * @param string $databaseId @@ -1925,7 +1925,7 @@ public function createRow(string $databaseId, string $tableId, string $rowId, ar /** * Create new Rows. Before using this route, you should create a new table * resource using either a [server - * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) * API or directly from your database console. * * @param string $databaseId @@ -1961,7 +1961,7 @@ public function createRows(string $databaseId, string $tableId, array $rows): ar /** * Create or update Rows. Before using this route, you should create a new * table resource using either a [server - * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) * API or directly from your database console. * * @@ -2115,7 +2115,7 @@ public function getRow(string $databaseId, string $tableId, string $rowId, ?arra /** * Create or update a Row. Before using this route, you should create a new * table resource using either a [server - * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) * API or directly from your database console. * * @param string $databaseId diff --git a/tests/Appwrite/Services/AccountTest.php b/tests/Appwrite/Services/AccountTest.php index b6a7be5..8b8c3e6 100644 --- a/tests/Appwrite/Services/AccountTest.php +++ b/tests/Appwrite/Services/AccountTest.php @@ -1285,6 +1285,28 @@ public function testMethodCreatePhoneToken(): void { $this->assertSame($data, $response); } + public function testMethodCreateEmailVerification(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->createEmailVerification( + "https://example.com" + ); + + $this->assertSame($data, $response); + } + public function testMethodCreateVerification(): void { $data = array( @@ -1307,6 +1329,29 @@ public function testMethodCreateVerification(): void { $this->assertSame($data, $response); } + public function testMethodUpdateEmailVerification(): void { + + $data = array( + "\$id" => "bb8ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c168bb8", + "secret" => "", + "expire" => "2020-10-15T06:38:00.000+00:00", + "phrase" => "Golden Fox",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->account->updateEmailVerification( + "", + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodUpdateVerification(): void { $data = array(