-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from naaando/add-laravel-pulse
Add laravel pulse
- Loading branch information
Showing
64 changed files
with
5,043 additions
and
558 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
pets-api/app/Http/Controllers/Auth/VerifyEmailController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Providers\RouteServiceProvider; | ||
use Illuminate\Auth\Events\Verified; | ||
use Illuminate\Foundation\Auth\EmailVerificationRequest; | ||
use Illuminate\Http\RedirectResponse; | ||
|
||
class VerifyEmailController extends Controller | ||
{ | ||
/** | ||
* Mark the authenticated user's email address as verified. | ||
*/ | ||
public function __invoke(EmailVerificationRequest $request): RedirectResponse | ||
{ | ||
if ($request->user()->hasVerifiedEmail()) { | ||
return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); | ||
} | ||
|
||
if ($request->user()->markEmailAsVerified()) { | ||
event(new Verified($request->user())); | ||
} | ||
|
||
return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Actions; | ||
|
||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Session; | ||
|
||
class Logout | ||
{ | ||
/** | ||
* Log the current user out of the application. | ||
*/ | ||
public function __invoke(): void | ||
{ | ||
Auth::guard('web')->logout(); | ||
|
||
Session::invalidate(); | ||
Session::regenerateToken(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Forms; | ||
|
||
use Illuminate\Auth\Events\Lockout; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\RateLimiter; | ||
use Illuminate\Support\Str; | ||
use Illuminate\Validation\ValidationException; | ||
use Livewire\Attributes\Validate; | ||
use Livewire\Form; | ||
|
||
class LoginForm extends Form | ||
{ | ||
#[Validate('required|string|email')] | ||
public string $email = ''; | ||
|
||
#[Validate('required|string')] | ||
public string $password = ''; | ||
|
||
#[Validate('boolean')] | ||
public bool $remember = false; | ||
|
||
/** | ||
* Attempt to authenticate the request's credentials. | ||
* | ||
* @throws \Illuminate\Validation\ValidationException | ||
*/ | ||
public function authenticate(): void | ||
{ | ||
$this->ensureIsNotRateLimited(); | ||
|
||
if (! Auth::attempt($this->only(['email', 'password']), $this->remember)) { | ||
RateLimiter::hit($this->throttleKey()); | ||
|
||
throw ValidationException::withMessages([ | ||
'email' => trans('auth.failed'), | ||
]); | ||
} | ||
|
||
RateLimiter::clear($this->throttleKey()); | ||
} | ||
|
||
/** | ||
* Ensure the authentication request is not rate limited. | ||
*/ | ||
protected function ensureIsNotRateLimited(): void | ||
{ | ||
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { | ||
return; | ||
} | ||
|
||
event(new Lockout(request())); | ||
|
||
$seconds = RateLimiter::availableIn($this->throttleKey()); | ||
|
||
throw ValidationException::withMessages([ | ||
'email' => trans('auth.throttle', [ | ||
'seconds' => $seconds, | ||
'minutes' => ceil($seconds / 60), | ||
]), | ||
]); | ||
} | ||
|
||
/** | ||
* Get the authentication rate limiting throttle key. | ||
*/ | ||
protected function throttleKey(): string | ||
{ | ||
return Str::transliterate(Str::lower($this->email).'|'.request()->ip()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use Livewire\Volt\Volt; | ||
|
||
class VoltServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register services. | ||
*/ | ||
public function register(): void | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Bootstrap services. | ||
*/ | ||
public function boot(): void | ||
{ | ||
Volt::mount([ | ||
resource_path('views/livewire'), | ||
resource_path('views/pages'), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\View\Components; | ||
|
||
use Illuminate\View\Component; | ||
use Illuminate\View\View; | ||
|
||
class AppLayout extends Component | ||
{ | ||
/** | ||
* Get the view / contents that represents the component. | ||
*/ | ||
public function render(): View | ||
{ | ||
return view('layouts.app'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\View\Components; | ||
|
||
use Illuminate\View\Component; | ||
use Illuminate\View\View; | ||
|
||
class GuestLayout extends Component | ||
{ | ||
/** | ||
* Get the view / contents that represents the component. | ||
*/ | ||
public function render(): View | ||
{ | ||
return view('layouts.guest'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.