46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Auth;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Validation\Rules\Password;
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Attributes\Title;
|
|
use Livewire\Component;
|
|
|
|
#[Layout('layouts.auth')]
|
|
#[Title('Passwort ändern — Clusev')]
|
|
class PasswordChange extends Component
|
|
{
|
|
public string $current = '';
|
|
|
|
public string $password = '';
|
|
|
|
public string $password_confirmation = '';
|
|
|
|
public function update()
|
|
{
|
|
$this->validate([
|
|
'current' => ['required', 'current_password'],
|
|
'password' => ['required', 'confirmed', Password::min(12)->mixedCase()->numbers()],
|
|
], attributes: [
|
|
'current' => 'aktuelles Passwort',
|
|
'password' => 'neues Passwort',
|
|
]);
|
|
|
|
Auth::user()->forceFill([
|
|
'password' => Hash::make($this->password),
|
|
'must_change_password' => false,
|
|
])->save();
|
|
|
|
// onboarding continues: the middleware sends an un-enrolled user to 2FA setup.
|
|
return $this->redirect(route('two-factor.setup'), navigate: true);
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.auth.password-change');
|
|
}
|
|
}
|