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
10 changes: 6 additions & 4 deletions docs/references/authentication/auth_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ public $views = [
## Defining New Actions

While the provided email-based activation and 2FA will work for many sites, others will have different
needs, like using SMS to verify or something completely different. Actions have only one requirement:
they must implement `CodeIgniter\Shield\Authentication\Actions\ActionInterface`.
needs, like using SMS to verify or something completely different. Custom actions must adhere to the following requirements:

The interface defines three methods for `ActionController`:
1. The class name for a "register" action must end with the suffix `Activator` (e.g., `SMSActivator`) to ensure consistency.
2. All custom actions must implement the `CodeIgniter\Shield\Authentication\Actions\ActionInterface`.

The `ActionInterface` defines three required methods that must be implemented to ensure the action integrates properly with the `ActionController`.

**show()** should display the initial page the user lands on immediately after the authentication task,
like login. It will typically display instructions to the user and provide an action to take, like
Expand All @@ -76,4 +78,4 @@ and provides feedback. In the `Email2FA` class, it verifies the code against wha
database and either sends them back to the previous form to try again or redirects the user to the
page that a `login` task would have redirected them to anyway.

All methods should return either a `Response` or a view string (e.g. using the `view()` function).
All methods should return either a `Response` or a view string (e.g. using the `view()` function).
5 changes: 5 additions & 0 deletions src/Config/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ class Auth extends BaseConfig
* - register: \CodeIgniter\Shield\Authentication\Actions\EmailActivator::class
* - login: \CodeIgniter\Shield\Authentication\Actions\Email2FA::class
*
* Custom Actions and Requirements:
*
* - All actions must implement \CodeIgniter\Shield\Authentication\Actions\ActionInterface.
* - Custom actions for "register" must have a class name that ends with the suffix "Activator" (e.g., `CustomSmsActivator`) ensure proper functionality.
*
* @var array<string, class-string<ActionInterface>|null>
*/
public array $actions = [
Expand Down
Loading