77Authentication Actions are a way to group actions that can happen after login or registration.
88Shield ships with two actions you can use, and makes it simple for you to define your own.
99
10- 1 . ** Email-based Two Factor Authentication** (Email2FA) will send a 6-digit code to the user's
10+ 1 . ** Email-based Account Activation** (EmailActivate) confirms a new user's email address by
11+ sending them an email with a link they must follow in order to have their account activated.
12+ 2 . ** Email-based Two Factor Authentication** (Email2FA) will send a 6-digit code to the user's
1113 email address that they must confirm before they can continue.
12- 2 . ** Email-based Account Activation** (EmailActivate) confirms a new user's email address by
13- sending them an email with a link they must follow in order to have their account activated.
1414
1515## Configuring Actions
1616
1717Actions are setup in the ` Auth ` config file, with the ` $actions ` variable.
1818
1919``` php
2020public $actions = [
21- 'login' => null,
2221 'register' => null,
22+ 'login' => null,
2323];
2424```
2525
2626To define an action to happen you will specify the class name as the value for the appropriate task:
2727
2828``` php
2929public $actions = [
30- 'login' => 'CodeIgniter\Shield\Authentication\Actions\Email2FA',
3130 'register' => 'CodeIgniter\Shield\Authentication\Actions\EmailActivator',
31+ 'login' => 'CodeIgniter\Shield\Authentication\Actions\Email2FA',
3232];
3333```
3434
35- Once configured, everything should work out of the box. The routes are added with the basic ` auth()->routes($routes) `
35+ You must register actions in the order of the actions to be performed.
36+ Once configured, everything should work out of the box.
37+
38+ The routes are added with the basic ` auth()->routes($routes) `
3639call, but can be manually added if you choose not to use this helper method.
3740
3841``` php
@@ -50,8 +53,8 @@ Views for all of these pages are defined in the `Auth` config file, with the `$v
5053 'action_email_2fa' => '\CodeIgniter\Shield\Views\email_2fa_show',
5154 'action_email_2fa_verify' => '\CodeIgniter\Shield\Views\email_2fa_verify',
5255 'action_email_2fa_email' => '\CodeIgniter\Shield\Views\Email\email_2fa_email',
53- 'action_email_activate_email' => '\CodeIgniter\Shield\Views\Email\email_activate_email',
5456 'action_email_activate_show' => '\CodeIgniter\Shield\Views\email_activate_show',
57+ 'action_email_activate_email' => '\CodeIgniter\Shield\Views\Email\email_activate_email',
5558 ];
5659```
5760
@@ -61,7 +64,7 @@ While the provided email-based activation and 2FA will work for many sites, othe
6164needs, like using SMS to verify or something completely different. Actions have only one requirement:
6265they must implement ` CodeIgniter\Shield\Authentication\Actions\ActionInterface ` .
6366
64- The interface defines three methods:
67+ The interface defines three methods for ` ActionController ` :
6568
6669** show()** should display the initial page the user lands on immediately after the authentication task,
6770like login. It will typically display instructions to the user and provide an action to take, like
@@ -77,4 +80,4 @@ and provides feedback. In the `Email2FA` class, it verifies the code against wha
7780database and either sends them back to the previous form to try again or redirects the user to the
7881page that a ` login ` task would have redirected them to anyway.
7982
80- All methods should return either a ` RedirectResponse ` or a view string (e.g. using the ` view() ` function).
83+ All methods should return either a ` Response ` or a view string (e.g. using the ` view() ` function).
0 commit comments