Feat: User deletion confirmation

This commit is contained in:
ayntk-ai
2024-09-04 21:14:18 +02:00
parent 44f3f6001e
commit f4263ee022
3 changed files with 26 additions and 16 deletions

View File

@@ -5,6 +5,8 @@ namespace App\Livewire\Team;
use App\Models\Team;
use App\Models\User;
use Livewire\Component;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class AdminView extends Component
{
@@ -73,8 +75,12 @@ class AdminView extends Component
$team->delete();
}
public function delete($id)
public function delete($id, $password)
{
if (!Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return;
}
if (! auth()->user()->isInstanceAdmin()) {
return $this->dispatch('error', 'You are not authorized to delete users');
}