# Authentication Actions

The authentication set of actions are used on pages that have custom login and registration screens.

{% content-ref url="/pages/-Ll3OG6bVwd0h-o49wNj" %}
[Custom Login Pages](/v1/reference/users-and-authentication/custom-login-pages.md)
{% endcontent-ref %}

* ***authLogin*** - Performs an authentication login
* ***authLogout*** - Performs logout
* ***authReset*** - Performs a password reset action
* ***authForgot** -* Performs a forgotten password reset hook
* \_**authVerify** \_ - Performs a verification of the verify token
* ***authResend*** - Re/sends the email verification token
* ***authRegister*** - Performs a registration and if successful, runs the [onRegistrationHook](/v1/reference/hooksoverview/commonoverview.md#onregistration)

Each of these actions should be attached to a button that the user will click to perform the respective task. They do not take any options, but some do require that an `email` and/or `password` key is present in your data model.

|  Action Name | Requires `email` key | Requires `password` key | Requires `token`\* |
| -----------: | :------------------: | :---------------------: | :----------------: |
|    authLogin |           ✅          |            ✅            |                    |
|   authLogout |                      |                         |                    |
|    authReset |                      |            ✅            |          ✅         |
|   authForgot |           ✅          |                         |                    |
|   authVerify |                      |                         |          ✅         |
|   authResend |           ✅          |                         |                    |
| authRegister |           ✅          |            ✅            |                    |

If these values are required, you should add validation to those fields and run a validate action before the authentication action.

The **authRegister** action does *not* require 2 password fields. If you want the user to enter their password twice before creating an account, you should create a [custom validator](/v1/reference/form-settings/validationoverview/clientside.md) that checks if the `password` key also matches some other `password2` key.

The **authReset** action doesn't require an email field, but it does require a valid `token` slug be present. The token is automatically generated and appended to the URL when you run the **authForgot** action, so you don't need to do anything with it on the page.

Similarly, the **authVerify** action only checks for the verification token in URL. It's recommended that this action be used within the onFormLoad named action as the user will be clicking the link in their email to get to this page.

## Error Handling

Authentication error messages will get added automatically to your [data model](/v1/reference/form-settings/data-model.md) under the `authMessage` key. You can display this info with any decoration you would like with an `html` element and some Vue syntax as follows:

```yaml
{
  "type": "html",
  "html": "<h2 class=\"warning\">{{model.authMessage}}</h2>",
  "styleClasses": "col-md-12"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.klai.studio/v1/reference/actions-processor/authentication-actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
