Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 13.3.0

* Deprecate `createVerification` method in `Account` service
* Add `createEmailVerification` method in `Account` service

## 11.1.0

* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
Expand Down
4 changes: 2 additions & 2 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def __init__(self):
self._endpoint = 'https://cloud.appwrite.io/v1'
self._global_headers = {
'content-type': '',
'user-agent' : f'AppwritePythonSDK/13.2.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
'user-agent' : f'AppwritePythonSDK/13.3.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
'x-sdk-name': 'Python',
'x-sdk-platform': 'server',
'x-sdk-language': 'python',
'x-sdk-version': '13.2.0',
'x-sdk-version': '13.3.0',
'X-Appwrite-Response-Format' : '1.8.0',
}

Expand Down
85 changes: 81 additions & 4 deletions appwrite/services/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,13 +1275,50 @@ def create_phone_token(self, user_id: str, phone: str) -> Dict[str, Any]:
'content-type': 'application/json',
}, api_params)

def create_email_verification(self, url: str) -> Dict[str, Any]:
"""
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
----------
url : str
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.

Returns
-------
Dict[str, Any]
API response as a dictionary

Raises
------
AppwriteException
If API request fails
"""

api_path = '/account/verifications/email'
api_params = {}
if url is None:
raise AppwriteException('Missing required parameter: "url"')


api_params['url'] = url

return self.client.call('post', api_path, {
'content-type': 'application/json',
}, api_params)

def create_verification(self, url: str) -> Dict[str, Any]:
"""
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.


.. deprecated::1.8.0
This API has been deprecated since 1.8.0. Please use `account.create_email_verification` instead.
Parameters
----------
url : str
Expand All @@ -1298,7 +1335,7 @@ def create_verification(self, url: str) -> Dict[str, Any]:
If API request fails
"""

api_path = '/account/verification'
api_path = '/account/verifications/email'
api_params = {}
if url is None:
raise AppwriteException('Missing required parameter: "url"')
Expand All @@ -1310,10 +1347,50 @@ def create_verification(self, url: str) -> Dict[str, Any]:
'content-type': 'application/json',
}, api_params)

def update_email_verification(self, user_id: str, secret: str) -> Dict[str, Any]:
"""
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
----------
user_id : str
User ID.
secret : str
Valid verification token.

Returns
-------
Dict[str, Any]
API response as a dictionary

Raises
------
AppwriteException
If API request fails
"""

api_path = '/account/verifications/email'
api_params = {}
if user_id is None:
raise AppwriteException('Missing required parameter: "user_id"')

if secret is None:
raise AppwriteException('Missing required parameter: "secret"')


api_params['userId'] = user_id
api_params['secret'] = secret

return self.client.call('put', api_path, {
'content-type': 'application/json',
}, api_params)

def update_verification(self, user_id: str, secret: str) -> Dict[str, Any]:
"""
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.

.. deprecated::1.8.0
This API has been deprecated since 1.8.0. Please use `account.update_email_verification` instead.
Parameters
----------
user_id : str
Expand All @@ -1332,7 +1409,7 @@ def update_verification(self, user_id: str, secret: str) -> Dict[str, Any]:
If API request fails
"""

api_path = '/account/verification'
api_path = '/account/verifications/email'
api_params = {}
if user_id is None:
raise AppwriteException('Missing required parameter: "user_id"')
Expand Down Expand Up @@ -1363,7 +1440,7 @@ def create_phone_verification(self) -> Dict[str, Any]:
If API request fails
"""

api_path = '/account/verification/phone'
api_path = '/account/verifications/phone'
api_params = {}

return self.client.call('post', api_path, {
Expand Down Expand Up @@ -1392,7 +1469,7 @@ def update_phone_verification(self, user_id: str, secret: str) -> Dict[str, Any]
If API request fails
"""

api_path = '/account/verification/phone'
api_path = '/account/verifications/phone'
api_params = {}
if user_id is None:
raise AppwriteException('Missing required parameter: "user_id"')
Expand Down
2 changes: 1 addition & 1 deletion appwrite/services/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def create_template_deployment(self, function_id: str, repository: str, owner: s
"""
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
----------
Expand Down
2 changes: 1 addition & 1 deletion appwrite/services/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def create_template_deployment(self, site_id: str, repository: str, owner: str,
"""
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
----------
Expand Down
Loading