Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Refactor password validation and update button label

Andras Bacsai7a3bb1465354
diff --git a/app/Livewire/Profile/Index.php b/app/Livewire/Profile/Index.php
index abfc0b9729..631d4f956f 100644
--- a/app/Livewire/Profile/Index.php
+++ b/app/Livewire/Profile/Index.php
@@ -11,11 +11,8 @@ class Index extends Component
public int $userId;
public string $email;
- #[Validate('required')]
public string $current_password;
- #[Validate('required|min:8')]
public string $new_password;
- #[Validate('required|min:8|same:new_password')]
public string $new_password_confirmation;
#[Validate('required')]
@@ -29,7 +26,9 @@ class Index extends Component
public function submit()
{
try {
- $this->validate();
+ $this->validate([
+ 'name' => 'required',
+ ]);
auth()->user()->update([
'name' => $this->name,
]);
@@ -42,7 +41,11 @@ class Index extends Component
public function resetPassword()
{
try {
- $this->validate();
+ $this->validate([
+ 'current_password' => 'required',
+ 'new_password' => 'required|min:8',
+ 'new_password_confirmation' => 'required|min:8|same:new_password',
+ ]);
if (!Hash::check($this->current_password, auth()->user()->password)) {
$this->dispatch('error', 'Current password is incorrect.');
return;
diff --git a/resources/views/livewire/profile/index.blade.php b/resources/views/livewire/profile/index.blade.php
index af4de1b2bb..8f4dfe62b0 100644
--- a/resources/views/livewire/profile/index.blade.php
+++ b/resources/views/livewire/profile/index.blade.php
@@ -13,8 +13,8 @@
</form>
<form wire:submit='resetPassword' class="flex flex-col max-w-xl pt-4">
<div class="flex items-center gap-2">
- <h2>Reset Password</h2>
- <x-forms.button type="submit" label="Save">Reset</x-forms.button>
+ <h2>Change Password</h2>
+ <x-forms.button type="submit" label="Save">Save</x-forms.button>
</div>
<div class="flex flex-col gap-2">
<x-forms.input id="current_password" label="Current Password" required type="password" />