authorize('machines.use'); } public function save(LoginPins $pins): void { $this->authorize('machines.use'); $this->resetErrorBag(); if (trim($this->pin) !== trim($this->pinConfirmation)) { $this->addError('pinConfirmation', __('users.pin.errors.confirmation')); return; } if ($this->passwordThrottled()) { return; } try { $pins->set((int) auth()->id(), $this->currentPassword, $this->pin); } catch (InvalidLoginPin) { $this->addError('pin', __('users.pin.errors.pin')); return; } catch (WrongPassword) { $this->wrongPassword(); return; } RateLimiter::clear($this->throttleKey()); $this->reset('currentPassword', 'pin', 'pinConfirmation'); $this->message = __('users.pin.saved'); } public function remove(LoginPins $pins): void { $this->authorize('machines.use'); $this->resetErrorBag(); if ($this->passwordThrottled()) { return; } try { $pins->remove((int) auth()->id(), $this->currentPassword); } catch (WrongPassword) { $this->wrongPassword(); return; } RateLimiter::clear($this->throttleKey()); $this->reset('currentPassword', 'pin', 'pinConfirmation'); $this->message = __('users.pin.removed'); } public function render(): mixed { return $this->view()->title(__('users.pin.title')); } private function throttleKey(): string { return 'pin-password|'.auth()->id(); } private function passwordThrottled(): bool { if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { return false; } $this->addError('currentPassword', __('auth.throttle', ['seconds' => RateLimiter::availableIn($this->throttleKey())])); $this->reset('currentPassword'); return true; } private function wrongPassword(): void { RateLimiter::hit($this->throttleKey()); $this->addError('currentPassword', __('users.pin.errors.password')); $this->reset('currentPassword'); } }; ?>

{{ __('users.pin.title') }}

{{ __('users.pin.intro') }}

{{ $message !== '' ? $message : (app(LoginPins::class)->has((int) auth()->id()) ? __('users.pin.is_set') : __('users.pin.not_set')) }}

@if (app(LoginPins::class)->has((int) auth()->id())) @endif