Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Added fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoraddatz committed Jan 26, 2024
1 parent c344fb5 commit 661ef21
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
10 changes: 3 additions & 7 deletions config/pin-login.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?php

use Empuxa\PinLogin\Events\LoggedInViaPin;
use Empuxa\PinLogin\Events\LoginRequestViaPin;
use Illuminate\Auth\Events\Lockout;

return [
/**
* The model to use for the login.
Expand Down Expand Up @@ -131,18 +127,18 @@
* This event is fired when a user submits a PIN.
* Default: \Empuxa\PinLogin\Events\PinRequested::class
*/
'login_request_via_pin' => LoginRequestViaPin::class,
'login_request_via_pin' => \Empuxa\PinLogin\Events\LoginRequestViaPin::class,

/**
* This event is fired when a user was successfully logged in.
* Default: \Empuxa\PinLogin\Events\LoggedInViaPin::class
*/
'logged_in_via_pin' => LoggedInViaPin::class,
'logged_in_via_pin' => \Empuxa\PinLogin\Events\LoggedInViaPin::class,

/**
* This event is fired when a user was successfully logged in.
* Default: \Illuminate\Auth\Events\Lockout::class
*/
'lockout' => Lockout::class,
'lockout' => \Illuminate\Auth\Events\Lockout::class,
],
];
3 changes: 2 additions & 1 deletion src/Controllers/HandleIdentifierRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Empuxa\PinLogin\Controllers;

use Empuxa\PinLogin\Events\LoginRequestViaPin;
use Empuxa\PinLogin\Jobs\CreateAndSendLoginPin;
use Empuxa\PinLogin\Requests\IdentifierRequest;
use Illuminate\Http\RedirectResponse;
Expand All @@ -26,7 +27,7 @@ public function __invoke(IdentifierRequest $request): RedirectResponse
config('pin-login.columns.identifier') => $identifierData,
]);

$event = config('pin-login.events.login_request_via_pin');
$event = config('pin-login.events.login_request_via_pin', LoginRequestViaPin::class);
event(new $event($user, $request));

return redirect(route('pin-login.pin.form'));
Expand Down
3 changes: 2 additions & 1 deletion src/Controllers/HandlePinRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Empuxa\PinLogin\Controllers;

use Empuxa\PinLogin\Events\LoggedInViaPin;
use Empuxa\PinLogin\Jobs\ResetLoginPin;
use Empuxa\PinLogin\Requests\PinRequest;
use Illuminate\Http\RedirectResponse;
Expand Down Expand Up @@ -34,7 +35,7 @@ public function __invoke(PinRequest $request): RedirectResponse

ResetLoginPin::dispatch($this->user);

$event = config('pin-login.events.logged_in_via_pin');
$event = config('pin-login.events.logged_in_via_pin', LoggedInViaPin::class);
event(new $event($this->user, $request));

return redirect()
Expand Down
3 changes: 2 additions & 1 deletion src/Requests/IdentifierRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Empuxa\PinLogin\Requests;

use Illuminate\Auth\Events\Lockout;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
Expand Down Expand Up @@ -44,7 +45,7 @@ public function ensureIsNotRateLimited(): void
return;
}

$event = config('pin-login.events.lockout');
$event = config('pin-login.events.lockout', Lockout::class);
event(new $event($this));

$seconds = RateLimiter::availableIn($this->throttleKey());
Expand Down

0 comments on commit 661ef21

Please sign in to comment.