name = Auth::user()->name; $this->email = Auth::user()->email; } public function updateProfile(): void { $data = $this->validate([ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'email', 'max:255', Rule::unique('users', 'email')->ignore(Auth::id())], ]); Auth::user()->update($data); $this->audit('profile.update', $data['email']); $this->dispatch('notify', message: __('settings.profile_saved')); } public function updatePassword(): void { $this->validate([ 'current_password' => ['required', 'current_password'], 'password' => ['required', 'confirmed', Password::min(10)], ]); Auth::user()->update(['password' => $this->password, 'must_change_password' => false]); $this->reset('current_password', 'password', 'password_confirmation'); $this->audit('password.change', Auth::user()->email); $this->dispatch('notify', message: __('settings.password_changed')); } public function confirmDisableTwoFactor(): void { $this->dispatch('openModal', component: 'modals.confirm-action', arguments: [ 'heading' => __('settings.disable_2fa_heading'), 'body' => __('settings.disable_2fa_body'), 'confirmLabel' => __('common.disable'), 'danger' => true, 'icon' => 'shield', 'auditAction' => 'two_factor.disable', 'auditTarget' => Auth::user()?->email, 'event' => 'twoFactorDisabled', 'notify' => __('settings.disable_2fa_notify'), ], ); } #[On('twoFactorDisabled')] public function disableTwoFactor(): void { Auth::user()->forceFill([ 'two_factor_secret' => null, 'two_factor_confirmed_at' => null, ])->save(); } private function audit(string $action, string $target): void { AuditEvent::create([ 'user_id' => Auth::id(), 'actor' => Auth::user()->name, 'action' => $action, 'target' => $target, 'ip' => request()->ip(), ]); } public function render() { return view('livewire.settings.index', [ 'twoFactorEnabled' => Auth::user()->hasTwoFactorEnabled(), ])->title(__('settings.title')); } }