Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 106ec24

Browse files
committed
remove getUser from websocket
1 parent c03c2fd commit 106ec24

File tree

3 files changed

+0
-38
lines changed

3 files changed

+0
-38
lines changed

src/Websocket/Authenticatable.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
namespace SwooleTW\Http\Websocket;
44

55
use InvalidArgumentException;
6-
use Illuminate\Support\Facades\Auth;
76
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
87

98
trait Authenticatable
109
{
11-
protected $user;
1210
protected $userId;
1311

1412
/**
@@ -57,22 +55,6 @@ public function toUserId($userIds)
5755
return $this;
5856
}
5957

60-
/**
61-
* Get current auth user by sender's fd.
62-
*/
63-
public function getUser()
64-
{
65-
if ($this->user instanceof AuthenticatableContract) {
66-
return $this->user;
67-
}
68-
69-
if (! is_null($uid = $this->getUserId()) && $user = Auth::loginUsingId($uid)) {
70-
$this->user = $user;
71-
}
72-
73-
return $this->user;
74-
}
75-
7658
/**
7759
* Get current auth user id by sender's fd.
7860
*/

src/Websocket/Websocket.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ public function reset($force = false)
317317

318318
if ($force) {
319319
$this->sender = null;
320-
$this->user = null;
321320
$this->userId = null;
322321
}
323322

tests/Websocket/WebsocketTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use InvalidArgumentException;
88
use Illuminate\Pipeline\Pipeline;
99
use SwooleTW\Http\Tests\TestCase;
10-
use Illuminate\Support\Facades\Auth;
1110
use SwooleTW\Http\Websocket\Websocket;
1211
use SwooleTW\Http\Websocket\Rooms\RoomContract;
1312
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
@@ -206,24 +205,6 @@ public function testGetUserId()
206205
$this->assertEquals($sender, $websocket->getUserId());
207206
}
208207

209-
public function testGetUser()
210-
{
211-
$room = m::mock(RoomContract::class);
212-
$room->shouldReceive('getRooms')
213-
->with($sender = 1)
214-
->once()
215-
->andReturn(['uid_1']);
216-
217-
$user = m::mock(AuthenticatableContract::class);
218-
Auth::shouldReceive('loginUsingId')
219-
->with($sender)
220-
->once()
221-
->andReturn($user);
222-
223-
$websocket = $this->getWebsocket($room)->setSender($sender);
224-
$this->assertEquals($user, $websocket->getUser());
225-
}
226-
227208
public function testReset()
228209
{
229210
$websocket = $this->getWebsocket();

0 commit comments

Comments
 (0)