You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Responding to Magic Link Logins](#responding-to-magic-link-logins)
17
+
-[Session Notification](#session-notification)
18
+
-[Event](#event)
17
19
-[Authorization Flow](#authorization-flow)
18
20
-[Change Available Groups](#change-available-groups)
19
21
-[Set the Default Group](#set-the-default-group)
@@ -131,10 +133,12 @@ public array $actions = [
131
133
132
134
Magic Link logins allow a user that has forgotten their password that have an email sent with a unique login link that will provide a one-time login for them. Once they've logged in you can decide how to respond. In some cases, you might want to redirect them to a special page where the must choose a new password. In other cases, you might simply want to display a one-time message prompting them to go to their account page and choose a new password there.
133
135
136
+
#### Session Notification
137
+
134
138
You can detect if a user has finished the magic link login by checking for a session value, `magic_link_login`. If they have recently completed the flow, it will exist and have a value of `true`.
135
139
136
140
```php
137
-
if (session('magic_link_login')) {
141
+
if (session('magic_login')) {
138
142
return redirect()->route('set_password');
139
143
}
140
144
```
@@ -145,6 +149,17 @@ This value sticks around in the session for 5 minutes. Once you no longer need t
145
149
session()->removeTempData('magic_link_login');
146
150
```
147
151
152
+
#### Event
153
+
154
+
At the same time the above session variable is set, a `magic_login`[event](https://codeigniter.com/user_guide/extending/events.html) is fired off that you may subscribe to. Note that no data is passed to the event as you can easily grab the current user from the `user()` helper or the `auth()->user()` method.
0 commit comments