Skip to content

Commit e782eb0

Browse files
authored
Merge pull request codeigniter4#1251 from datamweb/docs-require-Activator-in-class-name
docs: require `activator` in custom actions class name for `register`
2 parents 58d6d6f + 7c1ab83 commit e782eb0

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

docs/references/authentication/auth_actions.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ public $views = [
5757
## Defining New Actions
5858

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

63-
The interface defines three methods for `ActionController`:
62+
1. The class name for a "register" action must end with the suffix `Activator` (e.g., `SMSActivator`) to ensure consistency.
63+
2. All custom actions must implement the `CodeIgniter\Shield\Authentication\Actions\ActionInterface`.
64+
65+
The `ActionInterface` defines three required methods that must be implemented to ensure the action integrates properly with the `ActionController`.
6466

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

79-
All methods should return either a `Response` or a view string (e.g. using the `view()` function).
81+
All methods should return either a `Response` or a view string (e.g. using the `view()` function).

src/Config/Auth.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ class Auth extends BaseConfig
9595
* - register: \CodeIgniter\Shield\Authentication\Actions\EmailActivator::class
9696
* - login: \CodeIgniter\Shield\Authentication\Actions\Email2FA::class
9797
*
98+
* Custom Actions and Requirements:
99+
*
100+
* - All actions must implement \CodeIgniter\Shield\Authentication\Actions\ActionInterface.
101+
* - Custom actions for "register" must have a class name that ends with the suffix "Activator" (e.g., `CustomSmsActivator`) ensure proper functionality.
102+
*
98103
* @var array<string, class-string<ActionInterface>|null>
99104
*/
100105
public array $actions = [

0 commit comments

Comments
 (0)