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

## 19.1.0

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

## 16.1.0

* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
Expand Down
2 changes: 1 addition & 1 deletion appwrite.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |spec|

spec.name = 'appwrite'
spec.version = '19.0.0'
spec.version = '19.1.0'
spec.license = 'BSD-3-Clause'
spec.summary = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API'
spec.author = 'Appwrite Team'
Expand Down
14 changes: 14 additions & 0 deletions docs/examples/account/create-email-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'appwrite'

include Appwrite

client = Client.new
.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
.set_project('<YOUR_PROJECT_ID>') # Your project ID
.set_session('') # The user session to authenticate with

account = Account.new(client)

result = account.create_email_verification(
url: 'https://example.com'
)
15 changes: 15 additions & 0 deletions docs/examples/account/update-email-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

include Appwrite

client = Client.new
.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
.set_project('<YOUR_PROJECT_ID>') # Your project ID
.set_session('') # The user session to authenticate with

account = Account.new(client)

result = account.update_email_verification(
user_id: '<USER_ID>',
secret: '<SECRET>'
)
2 changes: 1 addition & 1 deletion lib/appwrite/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize
'x-sdk-name'=> 'Ruby',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'ruby',
'x-sdk-version'=> '19.0.0',
'x-sdk-version'=> '19.1.0',
'X-Appwrite-Response-Format' => '1.8.0'
}
@endpoint = 'https://cloud.appwrite.io/v1'
Expand Down
95 changes: 91 additions & 4 deletions lib/appwrite/services/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,52 @@ def create_phone_token(user_id:, phone:)
)
end

# 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 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.
#
# @return [Token]
def create_email_verification(url:)
api_path = '/account/verifications/email'

if url.nil?
raise Appwrite::Exception.new('Missing required parameter: "url"')
end

api_params = {
url: url,
}

api_headers = {
"content-type": 'application/json',
}

@client.call(
method: 'POST',
path: api_path,
headers: api_headers,
params: api_params,
response_type: Models::Token
)
end

#
# @deprecated This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.
#
# 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
Expand All @@ -1328,7 +1374,7 @@ def create_phone_token(user_id:, phone:)
#
# @return [Token]
def create_verification(url:)
api_path = '/account/verification'
api_path = '/account/verifications/email'

if url.nil?
raise Appwrite::Exception.new('Missing required parameter: "url"')
Expand All @@ -1351,6 +1397,47 @@ def create_verification(url:)
)
end

# 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] user_id User ID.
# @param [String] secret Valid verification token.
#
# @return [Token]
def update_email_verification(user_id:, secret:)
api_path = '/account/verifications/email'

if user_id.nil?
raise Appwrite::Exception.new('Missing required parameter: "userId"')
end

if secret.nil?
raise Appwrite::Exception.new('Missing required parameter: "secret"')
end

api_params = {
userId: user_id,
secret: secret,
}

api_headers = {
"content-type": 'application/json',
}

@client.call(
method: 'PUT',
path: api_path,
headers: api_headers,
params: api_params,
response_type: Models::Token
)
end

#
# @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.
#
# 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
Expand All @@ -1361,7 +1448,7 @@ def create_verification(url:)
#
# @return [Token]
def update_verification(user_id:, secret:)
api_path = '/account/verification'
api_path = '/account/verifications/email'

if user_id.nil?
raise Appwrite::Exception.new('Missing required parameter: "userId"')
Expand Down Expand Up @@ -1401,7 +1488,7 @@ def update_verification(user_id:, secret:)
#
# @return [Token]
def create_phone_verification()
api_path = '/account/verification/phone'
api_path = '/account/verifications/phone'

api_params = {
}
Expand Down Expand Up @@ -1429,7 +1516,7 @@ def create_phone_verification()
#
# @return [Token]
def update_phone_verification(user_id:, secret:)
api_path = '/account/verification/phone'
api_path = '/account/verifications/phone'

if user_id.nil?
raise Appwrite::Exception.new('Missing required parameter: "userId"')
Expand Down
2 changes: 1 addition & 1 deletion lib/appwrite/services/functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def create_duplicate_deployment(function_id:, deployment_id:, build_id: nil)
# 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] function_id Function ID.
Expand Down
4 changes: 2 additions & 2 deletions lib/appwrite/services/sites.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ def create_duplicate_deployment(site_id:, deployment_id:)
# 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] site_id Site ID.
# @param [String] repository Repository name of the template.
Expand Down
Loading