Method: Auth0::Api::V2::Tickets#post_email_verification

Defined in:
lib/auth0/api/v2/tickets.rb

#post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil, client_id: nil, organization_id: nil) ⇒ json

Create an email verification ticket After expiration, the ticket cannot be used to verify the user’s email. If not specified or if you send 0, the Auth0 default lifetime of five days will be applied

Parameters:

  • user_id (string)

    The user_id of for which the ticket is to be created.

  • result_url (string) (defaults to: nil)

    The user will be redirected to this endpoint once the ticket is used.

  • ttl_sec (integer) (defaults to: nil)

    The ticket’s lifetime in seconds starting from the moment of creation.

  • identity (hash) (defaults to: nil)

    Used to verify secondary, federated, and passwordless-email identities.

    • :user_id [string] user_id of the identity.

    • :provider [string] provider of the identity.

  • client_id (string) (defaults to: nil)

    client id

  • organization_id (string) (defaults to: nil)

    organization id

Returns:

  • (json)

    Returns the created ticket url.

See Also:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/auth0/api/v2/tickets.rb', line 22

def post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil, client_id: nil, organization_id: nil)
  if user_id.to_s.empty?
    raise Auth0::InvalidParameter, 'Must supply a valid user id to post an email verification'
  end
  path = "#{tickets_path}/email-verification"
  request_params = {
    user_id: user_id,
    result_url: result_url,
    ttl_sec: ttl_sec.is_a?(Integer) ? ttl_sec : nil
  }
  request_params[:client_id] = client_id unless client_id.nil?
  request_params[:organization_id] = organization_id unless organization_id.nil?

  if identity
    unless identity.is_a? Hash
      raise Auth0::InvalidParameter, 'Identity must be a hash to post an email verification'
    end
    request_params[:identity] = identity
  end

  post(path, request_params)
end