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
{{ message }}
This repository was archived by the owner on Apr 19, 2025. It is now read-only.
The first route is the route the user will be redirected to once the two-factor authentication process has been initiated. The second route is used to verify the two-factor authentication token that is to be entered by the user. The `showTwoFactorForm` controller method does exactly what it says. There do exist cases where you might want to respond differently however. For instance, instead of loading a view you might just want to return a `json` response. In that case you can simply overwrite `showTwoFactorForm` in the `TwoFactorAuthController` to be discussed below.
57
62
58
-
1 Add the following trait to `LoginController`:
63
+
1 Add the following import to `LoginController`:
59
64
```php
60
65
...
61
-
use MichaelDzjap\TwoFactorAuth\Http\Controllers\InitiatesTwoFactorAuthProcess;
66
+
use MichaelDzjap\TwoFactorAuth\Contracts\TwoFactorProvider;
62
67
63
68
class LoginController extends Controller
64
69
{
65
-
use AuthenticatesUsers, InitiatesTwoFactorAuthProcess;
66
70
...
67
71
```
68
72
and also add the following functions:
@@ -76,11 +80,35 @@ and also add the following functions:
76
80
*/
77
81
protected function authenticated(Request $request, $user)
* Provider specific two-factor authentication logic. In the case of MessageBird
86
114
* we just want to send an authentication token via SMS.
@@ -97,7 +125,7 @@ private function registerUserAndSendToken(User $user)
97
125
dispatch(new SendSMSToken($user));
98
126
}
99
127
```
100
-
The body of the second function can be left empty if you do not want to send a two-factor authentication token automatically after a successful login attempt. Instead, you might want the user to instantiate this process from the form him/herself. In that case you would have to add the required route(s) and controller method(s) yourself. The best place for this would be the `TwoFactorAuthController` to be discussed next.
128
+
You can discard the third function if you do not want to send a two-factor authentication token automatically after a successful login attempt. Instead, you might want the user to instantiate this process from the form him/herself. In that case you would have to add the required route and controller method to trigger this function yourself. The best place for this would be the `TwoFactorAuthController` to be discussed next.
101
129
102
130
2 Add a `TwoFactorAuthController` in `app/Http/Controllers/Auth` with the following content:
0 commit comments