Snapshot of main at 9f39a6e1e (2026-11-02)

This commit is contained in:
Ronald Huynen committed 2026-11-02 10:41:47 +01:00
commit 6ccf1792d7
2580 files changed
+1040202

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
<?php
namespace App\Http\Livewire\WireChat\New;
use Illuminate\Support\Facades\Auth;
use Namu\WireChat\Livewire\New\Chat as NewChat;
class Chat extends NewChat
{
// This magic accessor will be called for $this->auth
public function getAuthProperty()
{
// Use the active guard from session first, then fallback to checking all guards
$activeGuard = session('active_guard', 'web');
$user = Auth::guard($activeGuard)->user();
if ($user) {
return $user;
}
// Fallback to checking all guards if active guard doesn't have a user
return Auth::guard('admin')->user()
?: Auth::guard('bank')->user()
?: Auth::guard('organization')->user()
?: Auth::guard('web')->user();
}
/**
* Mount component (override with authorization)
*/
public function mount()
{
// CRITICAL SECURITY: Validate authorization on mount
$profile = getActiveProfile();
if (!$profile) {
abort(403, 'No active profile');
}
\App\Helpers\ProfileAuthorizationHelper::authorize($profile);
return parent::mount();
}
public function createConversation($id, string $class)
{
// CRITICAL SECURITY: Validate authorization before creating conversation
$profile = getActiveProfile();
if (!$profile) {
abort(403, 'No active profile');
}
\App\Helpers\ProfileAuthorizationHelper::authorize($profile);
$model = app($class);
$model = $model::find($id);
if ($model) {
$createdConversation = $this->auth->createConversationWith($model);
if ($createdConversation) {
$this->closeWireChatModal();
$this->handleComponentTermination(
redirectRoute: route(\Namu\WireChat\Facades\WireChat::viewRouteName(), [$createdConversation->id]),
events: [
\Namu\WireChat\Livewire\Widgets\WireChat::class => ['open-chat', ['conversation' => $createdConversation->id]],
]
);
}
}
}
}
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace App\Http\Livewire\WireChat\New;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Namu\WireChat\Facades\WireChat;
use Namu\WireChat\Livewire\New\Group as BaseGroup;
class Group extends BaseGroup
{
/**
* Add all linked users of the active Organization, Bank, or Admin profile
* to the selected members list, up to the group member limit.
*/
public function addLinkedMembers(): void
{
$activeProfile = getActiveProfile();
if (!$activeProfile) {
return;
}
\App\Helpers\ProfileAuthorizationHelper::authorize($activeProfile);
$activeProfileType = getActiveProfileType();
if (!in_array($activeProfileType, ['Organization', 'Bank', 'Admin'])) {
return;
}
$relationMethod = $activeProfileType === 'Bank' ? 'managers' : 'users';
$linkedUsers = $activeProfile->$relationMethod()
->select('users.id')
->get();
$maxMembers = WireChat::maxGroupMembers();
foreach ($linkedUsers as $linkedUser) {
// Stop if we've hit the group member limit
if (count($this->selectedMembers) >= $maxMembers) {
$this->dispatch('show-member-limit-error');
break;
}
$user = User::find($linkedUser->id);
if (!$user) {
continue;
}
// Skip if already selected
if ($this->selectedMembers->contains(fn ($m) => $m->id == $user->id && get_class($m) == get_class($user))) {
continue;
}
$this->selectedMembers->push($user);
}
}
}