presseportale/resources/views/livewire/settings/password.blade.php
Kevin Adametz 9b47296cea
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
Rebrand Hub+Flux
2026-05-20 15:44:15 +02:00

80 lines
2.6 KiB
PHP

<?php
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules\Password;
use Illuminate\Validation\ValidationException;
use Livewire\Attributes\Layout;
use Livewire\Volt\Component;
new #[Layout('components.layouts.app')] class extends Component
{
public string $current_password = '';
public string $password = '';
public string $password_confirmation = '';
/**
* Update the password for the currently authenticated user.
*/
public function updatePassword(): void
{
try {
$validated = $this->validate([
'current_password' => ['required', 'string', 'current_password'],
'password' => ['required', 'string', Password::defaults(), 'confirmed'],
]);
} catch (ValidationException $e) {
$this->reset('current_password', 'password', 'password_confirmation');
throw $e;
}
Auth::user()->update([
'password' => Hash::make($validated['password']),
]);
$this->reset('current_password', 'password', 'password_confirmation');
$this->dispatch('password-updated');
}
}; ?>
<section class="w-full">
@include('partials.settings-heading')
<x-settings.layout :heading="__('Update password')" :subheading="__('Ensure your account is using a long, random password to stay secure')">
<form wire:submit="updatePassword" class="space-y-5">
<flux:input
wire:model="current_password"
:label="__('Current password')"
type="password"
required
autocomplete="current-password"
/>
<flux:input
wire:model="password"
:label="__('New password')"
type="password"
required
autocomplete="new-password"
/>
<flux:input
wire:model="password_confirmation"
:label="__('Confirm Password')"
type="password"
required
autocomplete="new-password"
/>
<div class="flex items-center gap-4 pt-2 border-t border-[color:var(--color-bg-rule)]">
<flux:button variant="primary" type="submit">{{ __('Save') }}</flux:button>
<x-action-message on="password-updated">
<span class="text-[12px] text-[color:var(--color-gain-deep)]">{{ __('Saved.') }}</span>
</x-action-message>
</div>
</form>
</x-settings.layout>
</section>