12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
5b8bdf4182
779 changed files with 480564 additions and 6241 deletions
|
|
@ -1,7 +1,11 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Auth\Events\Lockout;
|
||||
use App\Mail\MagicLoginLink;
|
||||
use App\Services\Auth\MagicLinkGenerator;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
|
@ -37,12 +41,42 @@ new #[Layout('components.layouts.auth')] class extends Component {
|
|||
]);
|
||||
}
|
||||
|
||||
$authenticatedUser = Auth::user();
|
||||
if ($authenticatedUser) {
|
||||
$authenticatedUser->update([
|
||||
'last_login_at' => now(),
|
||||
'last_login_ip' => request()->ip(),
|
||||
]);
|
||||
}
|
||||
|
||||
RateLimiter::clear($this->throttleKey());
|
||||
Session::regenerate();
|
||||
|
||||
$this->redirectIntended(default: route('dashboard', absolute: false), navigate: true);
|
||||
}
|
||||
|
||||
public function sendMagicLink(): void
|
||||
{
|
||||
$this->validateOnly('email');
|
||||
|
||||
$user = User::query()->where('email', $this->email)->first();
|
||||
|
||||
if ($user && $user->is_active) {
|
||||
$generated = app(MagicLinkGenerator::class)->createLoginLink($user, request()->ip());
|
||||
$loginUrl = route('magic-links.consume', ['token' => $generated['plain_token']]);
|
||||
|
||||
Mail::to($user->email)->send(
|
||||
new MagicLoginLink(
|
||||
user: $user,
|
||||
loginUrl: $loginUrl,
|
||||
expiresAt: $generated['expires_at']->format('d.m.Y H:i')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
session()->flash('status', __('If an active account exists for this email, we sent a magic login link.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the authentication request is not rate limited.
|
||||
*/
|
||||
|
|
@ -117,6 +151,15 @@ new #[Layout('components.layouts.auth')] class extends Component {
|
|||
</div>
|
||||
</form>
|
||||
|
||||
<div class="rounded-lg border border-zinc-200 p-4 dark:border-zinc-700">
|
||||
<p class="mb-3 text-sm text-zinc-600 dark:text-zinc-300">
|
||||
{{ __('Login without password? Request a one-time email link.') }}
|
||||
</p>
|
||||
<flux:button variant="subtle" wire:click="sendMagicLink" class="w-full">
|
||||
{{ __('Send magic login link') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
|
||||
@if (Route::has('register'))
|
||||
<div class="space-x-1 text-center text-sm text-zinc-600 dark:text-zinc-400">
|
||||
{{ __('Don\'t have an account?') }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue