Skip to content

Commit

Permalink
few minor patches for additional session checks on resources
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Oct 10, 2024
1 parent bc51456 commit ba8a66b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Http/Resources/ChatChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ChatChannel extends FleetbaseResource
*/
public function toArray($request)
{
$user = Auth::getUserFromSession();
$user = $request->hasSession() ? Auth::getUserFromSession($request) : null;

return [
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
Expand All @@ -28,7 +28,7 @@ public function toArray($request)
'name' => $this->name,
'title' => $this->title,
'last_message' => new ChatMessage($this->last_message),
'unread_count' => $this->getUnreadMessageCountForUser($user),
'unread_count' => $this->when($user, fn () => $this->getUnreadMessageCountForUser($user)),
'slug' => $this->slug,
'feed' => $this->resource_feed,
'participants' => ChatParticipant::collection($this->participants),
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Resources/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function toArray($request)
'meta' => $this->meta,
'author' => new Author($this->author),
'replies' => static::collection($this->replies),
'editable' => $this->when(Http::isInternalRequest(), session('user') === $this->author_uuid),
'editable' => $this->when(Http::isInternalRequest(), $request->hasSession() && session('user') === $this->author_uuid),
'updated_at' => $this->updated_at,
'created_at' => $this->created_at,
'deleted_at' => $this->deleted_at,
Expand Down

0 comments on commit ba8a66b

Please sign in to comment.