feat: force password reset + waitlist
This commit is contained in:
36
app/Http/Livewire/ForcePasswordReset.php
Normal file
36
app/Http/Livewire/ForcePasswordReset.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Livewire\Component;
|
||||
|
||||
class ForcePasswordReset extends Component
|
||||
{
|
||||
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 {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
49
app/Http/Livewire/Waitlist.php
Normal file
49
app/Http/Livewire/Waitlist.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Jobs\SendConfirmationForWaitlistJob;
|
||||
use App\Models\Waitlist as ModelsWaitlist;
|
||||
use Livewire\Component;
|
||||
|
||||
class Waitlist extends Component
|
||||
{
|
||||
public string $email;
|
||||
public int $waiting_in_line = 0;
|
||||
|
||||
protected $rules = [
|
||||
'email' => 'required|email',
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
if (is_dev()) {
|
||||
$this->email = 'test@example.com';
|
||||
}
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
try {
|
||||
$found = ModelsWaitlist::where('email', $this->email)->first();
|
||||
ray($found);
|
||||
if ($found) {
|
||||
if (!$found->verified) {
|
||||
$this->emit('error', 'You are already on the waitlist. <br>Please check your email to verify your email address.');
|
||||
return;
|
||||
}
|
||||
$this->emit('error', 'You are already on the waitlist.');
|
||||
return;
|
||||
}
|
||||
$waitlist = ModelsWaitlist::create([
|
||||
'email' => $this->email,
|
||||
'type' => 'registration',
|
||||
]);
|
||||
|
||||
$this->emit('success', 'You have been added to the waitlist.');
|
||||
dispatch(new SendConfirmationForWaitlistJob($this->email, $waitlist->uuid));
|
||||
} catch (\Exception $e) {
|
||||
return general_error_handler(err: $e, that: $this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user