$wsOptIn module, you can implement token-based opt-in processes in the frontend. Typical use cases are email verification, newsletter confirmation, or password reset. In this section, you will learn how to create opt-in links and check token validity.
Module overview
Example / excerpt of$wsOptIn
ƒ() denotes a function.
Variables and methods overview:
| Variable | Type | Description |
|---|---|---|
current | map | Returns a map with info about the active token, if one was passed in the request. |
valid | bool | Returns true if the passed token is valid. |
token | string | Returns the passed token as text. |
createTokenUrl() | string | Creates an opt-in URL with a secure token. |
Templates
The$wsOptIn module is typically used for account functions such as resetting a password or creating an account.
Variables
$wsOptIn.current
Contains information about the token passed in the current URL. Isnull if no token is present in the URL.
$wsOptIn.current.valid
Returnstrue / false if the passed token is valid / invalid.
$wsOptIn.current.token
Returns the passed token.Methods
$wsOptIn.createTokenUrl()
Creates an opt-in URL with a secure token. The token is generated automatically and appended to the specified URL. This URL can then be sent to the customer by email. Signature$wsOptIn.createTokenUrl(url, tokenName)
Return valuestring - URL with appended token parameter.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url | string | yes | Base URL to which the token is appended. |
tokenName | string | yes | Name of the token (e.g. "verifyEmail"). |
Actions
No actions are available for$wsOptIn.
Examples for data access
Confirming the email address via opt-in link
After creating a user account in the shop, the user receives an email to confirm their email address, e.g.emailVerify.htm) is opened, it checks whether the token is valid. If so, they can complete the verification with a button click.
