Skip to content

Commit

Permalink
Revert "[8.x] Protect against ambiguous columns (#43278)" (#43362)
Browse files Browse the repository at this point in the history
This reverts commit a6d9307.
  • Loading branch information
driesvints committed Jul 22, 2022
1 parent 1b3b06e commit 472466e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/EloquentUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function retrieveById($identifier)
$model = $this->createModel();

return $this->newModelQuery($model)
->where($model->qualifyColumn($model->getAuthIdentifierName()), $identifier)
->where($model->getAuthIdentifierName(), $identifier)
->first();
}

Expand All @@ -65,7 +65,7 @@ public function retrieveByToken($identifier, $token)
$model = $this->createModel();

$retrievedModel = $this->newModelQuery($model)->where(
$model->qualifyColumn($model->getAuthIdentifierName()), $identifier
$model->getAuthIdentifierName(), $identifier
)->first();

if (! $retrievedModel) {
Expand Down
12 changes: 4 additions & 8 deletions tests/Auth/AuthEloquentUserProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public function testRetrieveByIDReturnsUser()
$mock = m::mock(stdClass::class);
$mock->shouldReceive('newQuery')->once()->andReturn($mock);
$mock->shouldReceive('getAuthIdentifierName')->once()->andReturn('id');
$mock->shouldReceive('qualifyColumn')->with('id')->andReturn('users.id');
$mock->shouldReceive('where')->once()->with('users.id', 1)->andReturn($mock);
$mock->shouldReceive('where')->once()->with('id', 1)->andReturn($mock);
$mock->shouldReceive('first')->once()->andReturn('bar');
$provider->expects($this->once())->method('createModel')->willReturn($mock);
$user = $provider->retrieveById(1);
Expand All @@ -40,8 +39,7 @@ public function testRetrieveByTokenReturnsUser()
$mock = m::mock(stdClass::class);
$mock->shouldReceive('newQuery')->once()->andReturn($mock);
$mock->shouldReceive('getAuthIdentifierName')->once()->andReturn('id');
$mock->shouldReceive('qualifyColumn')->with('id')->andReturn('users.id');
$mock->shouldReceive('where')->once()->with('users.id', 1)->andReturn($mock);
$mock->shouldReceive('where')->once()->with('id', 1)->andReturn($mock);
$mock->shouldReceive('first')->once()->andReturn($mockUser);
$provider->expects($this->once())->method('createModel')->willReturn($mock);
$user = $provider->retrieveByToken(1, 'a');
Expand All @@ -55,8 +53,7 @@ public function testRetrieveTokenWithBadIdentifierReturnsNull()
$mock = m::mock(stdClass::class);
$mock->shouldReceive('newQuery')->once()->andReturn($mock);
$mock->shouldReceive('getAuthIdentifierName')->once()->andReturn('id');
$mock->shouldReceive('qualifyColumn')->with('id')->andReturn('users.id');
$mock->shouldReceive('where')->once()->with('users.id', 1)->andReturn($mock);
$mock->shouldReceive('where')->once()->with('id', 1)->andReturn($mock);
$mock->shouldReceive('first')->once()->andReturn(null);
$provider->expects($this->once())->method('createModel')->willReturn($mock);
$user = $provider->retrieveByToken(1, 'a');
Expand All @@ -81,8 +78,7 @@ public function testRetrieveByBadTokenReturnsNull()
$mock = m::mock(stdClass::class);
$mock->shouldReceive('newQuery')->once()->andReturn($mock);
$mock->shouldReceive('getAuthIdentifierName')->once()->andReturn('id');
$mock->shouldReceive('qualifyColumn')->with('id')->andReturn('users.id');
$mock->shouldReceive('where')->once()->with('users.id', 1)->andReturn($mock);
$mock->shouldReceive('where')->once()->with('id', 1)->andReturn($mock);
$mock->shouldReceive('first')->once()->andReturn($mockUser);
$provider->expects($this->once())->method('createModel')->willReturn($mock);
$user = $provider->retrieveByToken(1, 'a');
Expand Down

0 comments on commit 472466e

Please sign in to comment.