2023-08-15 12:11:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
2023-08-15 12:27:45 +00:00
|
|
|
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
|
2023-08-15 12:11:38 +00:00
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class ForcePasswordReset extends Component
|
|
|
|
{
|
2023-08-15 12:27:45 +00:00
|
|
|
use WithRateLimiting;
|
2023-08-15 12:11:38 +00:00
|
|
|
public string $email;
|
|
|
|
public string $password;
|
|
|
|
public string $password_confirmation;
|
|
|
|
|
|
|
|
protected $rules = [
|
|
|
|
'email' => 'required|email',
|
|
|
|
'password' => 'required|min:8',
|
|
|
|
'password_confirmation' => 'required|same:password',
|
|
|
|
];
|
|
|
|
public function mount() {
|
|
|
|
$this->email = auth()->user()->email;
|
|
|
|
}
|
|
|
|
public function submit() {
|
|
|
|
try {
|
2023-08-15 12:27:45 +00:00
|
|
|
$this->rateLimit(10);
|
2023-08-15 12:11:38 +00:00
|
|
|
$this->validate();
|
|
|
|
auth()->user()->forceFill([
|
|
|
|
'password' => Hash::make($this->password),
|
|
|
|
'force_password_reset' => false,
|
|
|
|
])->save();
|
|
|
|
auth()->logout();
|
|
|
|
return redirect()->route('login')->with('status', 'Your initial password has been set.');
|
|
|
|
} catch(\Exception $e) {
|
|
|
|
return general_error_handler(err:$e, that:$this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|