OAuth users don't have passwords set, so they should not be prompted for password confirmation when performing destructive actions. This fix: - Detects OAuth users via the hasPassword() method - Skips password confirmation in modal for OAuth users - Keeps text name confirmation as the final step - Centralizes logic in helper functions for maintainability - Changes button text to "Confirm" when password step is skipped Fixes #4457 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Livewire\Component;
|
|
|
|
class NavbarDeleteTeam extends Component
|
|
{
|
|
public $team;
|
|
|
|
public function mount()
|
|
{
|
|
$this->team = currentTeam()->name;
|
|
}
|
|
|
|
public function delete($password)
|
|
{
|
|
if (! verifyPasswordConfirmation($password, $this)) {
|
|
return;
|
|
}
|
|
|
|
$currentTeam = currentTeam();
|
|
$currentTeam->delete();
|
|
|
|
$currentTeam->members->each(function ($user) use ($currentTeam) {
|
|
if ($user->id === Auth::id()) {
|
|
return;
|
|
}
|
|
$user->teams()->detach($currentTeam);
|
|
$session = DB::table('sessions')->where('user_id', $user->id)->first();
|
|
if ($session) {
|
|
DB::table('sessions')->where('id', $session->id)->delete();
|
|
}
|
|
});
|
|
|
|
refreshSession();
|
|
|
|
return redirect()->route('team.index');
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.navbar-delete-team');
|
|
}
|
|
}
|