Skip to content

Commit bb9c1fd

Browse files
lonnieezellkenjis
authored andcommitted
Addressing review comments
1 parent b2d51ca commit bb9c1fd

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

docs/events.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Shield fires off several events during the lifecycle of the application that you
99
- [login](#login)
1010
- [failedLogin](#failedlogin)
1111
- [logout](#logout)
12+
- [magicLogin](#magiclogin)
13+
- [Event Timing](#event-timing)
1214

1315
## Responding to Events
1416

@@ -66,6 +68,18 @@ When the magic link login fails, the following array will be provided:
6668

6769
Fired immediately after a successful logout. The only argument is the `User` entity.
6870

71+
#### magicLogin
72+
73+
Fired when a user has been successfully logged in via a magic link. This event does not have any parameters passed in. The authenticated user can be discovered through the `auth()` helper.
74+
75+
```php
76+
Events::on('magicLogin', function() {
77+
$user = auth()->user();
78+
79+
//
80+
})
81+
```
82+
6983
### Event Timing
7084

7185
To learn more about Event timing, please see the list below.

docs/session_auth_event_and_logging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ The following is a list of Events and Logging for Session Authenticator.
3838
- OK → no event
3939
- NG → no event
4040
2. Send request with token
41-
- OK → event `login` / table `auth_logins`
41+
- OK → event `login` and `magicLogin` / table `auth_logins`
4242
- NG → event `failedLogin` / table `auth_logins`

src/Controllers/MagicLinkController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ public function verify(): RedirectResponse
165165

166166
// Give the developer a way to know the user
167167
// logged in via a magic link.
168-
session()->setTempdata('magic_login', true);
168+
session()->setTempdata('magicLogin', true);
169169

170-
Events::trigger('magic_login');
170+
Events::trigger('magicLogin');
171171

172172
// Get our login redirect url
173173
return redirect()->to(config('Auth')->loginRedirect());

0 commit comments

Comments
 (0)