File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace PragmaRX \Google2FALaravel \Listeners ;
4+
5+ use Illuminate \Auth \Events \Login ;
6+ use Illuminate \Support \Facades \Auth ;
7+ use Illuminate \Contracts \Auth \Authenticatable as User ;
8+ use PragmaRX \Google2FALaravel \Facade as Google2FA ;
9+
10+ class LoginViaRemember
11+ {
12+ /**
13+ * Handle the event.
14+ *
15+ * @param \Illuminate\Auth\Events\Login $event
16+ * @return void
17+ */
18+ public function handle (Login $ event )
19+ {
20+ if (Auth::viaRemember ()) {
21+ $ this ->registerGoogle2fa ($ event ->user );
22+ }
23+ }
24+
25+ /**
26+ * Force register Google2fa login.
27+ *
28+ * @param User $user
29+ */
30+ private function registerGoogle2fa (User $ user )
31+ {
32+ $ secret = $ user ->{Google2FA::config ('otp_secret_column ' )};
33+
34+ if (!is_null ($ secret ) && !empty ($ secret )) {
35+ Google2FA::login ();
36+ }
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments