This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
generated from spatie/package-skeleton-laravel
-
-
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.
- Loading branch information
1 parent
665aa94
commit 32b3ea9
Showing
35 changed files
with
378 additions
and
114 deletions.
There are no files selected for viewing
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,24 @@ | ||
<x-ui-container class="flex h-screen items-center justify-center"> | ||
<x-ui-card> | ||
<form wire:submit="submit"> | ||
<x-forms-input | ||
wire:model="form.email" | ||
type="email" | ||
label="{{ __('Email') }}" | ||
required | ||
autofocus | ||
/> | ||
|
||
<x-forms-input | ||
wire:model="form.password" | ||
type="password" | ||
label="{{ __('Password') }}" | ||
required | ||
/> | ||
|
||
<x-ui-button type="submit"> | ||
{{ __('Login') }} | ||
</x-ui-button> | ||
</form> | ||
</x-ui-card> | ||
</x-ui-container> |
This file was deleted.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
resources/views/forms/text-input.blade.php → resources/views/forms/input.blade.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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<label class="label"> | ||
<span>{{ $label }}</span> | ||
|
||
@if ($attributes->get('required')) | ||
@if ($required) | ||
<span class="text-error">*</span> | ||
@endif | ||
</label> |
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,5 @@ | ||
<div class="card"> | ||
{{ $slot }} | ||
|
||
{{ $actions }} | ||
</div> |
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,30 @@ | ||
<?php | ||
|
||
namespace Foxws\LivewireUse\Auth\Controllers; | ||
|
||
use Foxws\LivewireUse\Auth\Forms\LoginForm; | ||
use Foxws\LivewireUse\Views\Components\Page; | ||
use Livewire\Attributes\Layout; | ||
|
||
#[Layout('components.layouts.auth')] | ||
class LoginController extends Page | ||
{ | ||
protected static string $view = 'auth.login'; | ||
|
||
public LoginForm $form; | ||
|
||
public function mount(): void | ||
{ | ||
$this->seo()->setTitle(__('Login')); | ||
$this->seo()->setDescription(__('Login to Account')); | ||
|
||
if (static::isAuthenticated()) { | ||
redirect()->intended(); | ||
} | ||
} | ||
|
||
public function submit(): void | ||
{ | ||
$this->form->submit(); | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace Foxws\LivewireUse\Auth\Forms; | ||
|
||
use Foxws\LivewireUse\Forms\Components\Form; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Validation\Rules\Password; | ||
use Livewire\Attributes\Validate; | ||
|
||
class LoginForm extends Form | ||
{ | ||
protected static int $maxAttempts = 5; | ||
|
||
#[Validate] | ||
public ?string $email = null; | ||
|
||
#[Validate] | ||
public ?string $password = null; | ||
|
||
public function rules(): array | ||
{ | ||
return [ | ||
'email' => 'required|email', | ||
'password' => [ | ||
'required', | ||
Password::defaults(), | ||
], | ||
]; | ||
} | ||
|
||
protected function handle() | ||
{ | ||
if (Auth::attempt($this->all())) { | ||
session()->regenerate(); | ||
|
||
return redirect()->intended(); | ||
} | ||
|
||
$this->addError('email', __('These credentials do not match our records')); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace Foxws\LivewireUse\Exceptions; | ||
|
||
use Exception; | ||
|
||
class RateLimitedException extends Exception | ||
{ | ||
public int $minutesUntilAvailable = 0; | ||
|
||
public function __construct( | ||
public string $ip, | ||
public int $secondsUntilAvailable, | ||
) { | ||
$this->minutesUntilAvailable = ceil($this->secondsUntilAvailable / 60); | ||
|
||
parent::__construct(sprintf( | ||
'Too many requests from [%s]. Retry in %d seconds.', | ||
$this->ip, | ||
$this->secondsUntilAvailable, | ||
)); | ||
} | ||
} |
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
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,29 @@ | ||
<?php | ||
|
||
namespace Foxws\LivewireUse\Forms\Concerns; | ||
|
||
use Foxws\LivewireUse\Exceptions\RateLimitedException; | ||
use Foxws\LivewireUse\Views\Concerns\WithRateLimiting; | ||
|
||
trait WithThrottle | ||
{ | ||
use WithRateLimiting; | ||
|
||
protected function handleThrottle(RateLimitedException $e): void | ||
{ | ||
$field = $this->getThrottleModel(); | ||
|
||
$this->resetErrorBag($field); | ||
|
||
$this->addError($field, __('Please retry in :seconds seconds', [ | ||
'seconds' => $e->secondsUntilAvailable ?? 0, | ||
])); | ||
} | ||
|
||
protected function getThrottleModel(): string | ||
{ | ||
$fields = array_keys($this->all()); | ||
|
||
return $fields[0] ?? 'throttled'; | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace Foxws\LivewireUse\Forms\Concerns; | ||
|
||
trait WithValidation | ||
{ | ||
protected static bool $recoverable = false; | ||
|
||
public function check(): void | ||
{ | ||
if (! static::$recoverable) { | ||
$this->validate(); | ||
|
||
return; | ||
} | ||
|
||
rescue( | ||
fn () => $this->validate(), | ||
fn () => $this->reset(), | ||
); | ||
} | ||
} |
Oops, something went wrong.