restore: bring back f8a1310 (security review) state

Restores all files to the f8a1310 security-review snapshot as requested,
plus the 2 boot-critical fixes from a24c8a2 (config/session.php env()
instead of app()->environment(), and removal of the duplicate $activeTab
in ProjectMap.php) so the application actually boots.

Forward commit, no history rewrite. The 7d854ff state remains in history.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-17 10:36:44 +02:00
parent c44958ac16
commit 941dbd5997
26 changed files with 1163 additions and 1196 deletions
+34 -15
View File
@@ -9,38 +9,57 @@ use Illuminate\Support\Facades\Auth;
class AdminUsers extends Component
{
public string $search = '';
public $users;
public $roles;
public function mount(): void
public function mount()
{
if (!Auth::user()->hasRole('Admin')) abort(403);
$this->roles = Role::orderBy('name')->get();
if (!Auth::user()->hasRole('Admin')) {
abort(403);
}
$this->roles = Role::all();
$this->loadUsers();
}
public function getUsersProperty()
public function loadUsers()
{
return User::with('roles')
->when($this->search, fn($q) =>
$q->where(fn($q2) => $q2
->where('name', 'like', '%' . $this->search . '%')
->orWhere('email', 'like', '%' . $this->search . '%')))
->orderBy('name')
->get();
$this->users = User::with('roles')->orderBy('name')->get();
}
public function updateRole($userId, $roleName)
{
$user = Auth::user();
if (!$user->hasRole('Admin')) {
session()->flash('error', 'Solo administradores.');
return;
}
$targetUser = User::findOrFail($userId);
if ($targetUser->id === $user->id && $targetUser->hasRole('Admin')) {
session()->flash('error', 'No puedes cambiarte el rol a ti mismo.');
return;
}
$targetUser->syncRoles([$roleName]);
$this->loadUsers();
$this->dispatch('notify', 'Rol actualizado.');
}
public function deleteUser(int $userId): void
{
if (!Auth::user()->hasRole('Admin')) abort(403);
if ($userId === Auth::id()) {
$this->dispatch('notify', 'No puedes eliminarte a ti mismo.');
session()->flash('error', 'No puedes eliminarte a ti mismo.');
return;
}
User::findOrFail($userId)->delete();
$this->dispatch('notify', 'Usuario eliminado.');
session()->flash('message', 'Usuario eliminado.');
$this->loadUsers();
}
public function render()
{
return view('livewire.admin-users');
}
}
}