Skip to content

Commit

Permalink
Remove password rule
Browse files Browse the repository at this point in the history
  • Loading branch information
netpok committed Sep 29, 2021
1 parent 12d6652 commit 1f54941
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 107 deletions.
13 changes: 0 additions & 13 deletions src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -1369,19 +1369,6 @@ public function validateNumeric($attribute, $value)
return is_numeric($value);
}

/**
* Validate that the password of the currently authenticated user matches the given value.
*
* @param string $attribute
* @param mixed $value
* @param array $parameters
* @return bool
*/
protected function validatePassword($attribute, $value, $parameters)
{
return $this->validateCurrentPassword($attribute, $value, $parameters);
}

/**
* Validate that an attribute exists even if not filled.
*
Expand Down
94 changes: 0 additions & 94 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -880,100 +880,6 @@ public function testValidationStopsAtFailedPresenceCheck()
$this->assertEquals(['validation.present'], $v->errors()->get('name'));
}

public function testValidatePassword()
{
// Fails when user is not logged in.
$auth = m::mock(Guard::class);
$auth->shouldReceive('guard')->andReturn($auth);
$auth->shouldReceive('guest')->andReturn(true);

$hasher = m::mock(Hasher::class);

$container = m::mock(Container::class);
$container->shouldReceive('make')->with('auth')->andReturn($auth);
$container->shouldReceive('make')->with('hash')->andReturn($hasher);

$trans = $this->getTranslator();
$trans->shouldReceive('get')->andReturnArg(0);

$v = new Validator($trans, ['password' => 'foo'], ['password' => 'password']);
$v->setContainer($container);

$this->assertFalse($v->passes());

// Fails when password is incorrect.
$user = m::mock(Authenticatable::class);
$user->shouldReceive('getAuthPassword');

$auth = m::mock(Guard::class);
$auth->shouldReceive('guard')->andReturn($auth);
$auth->shouldReceive('guest')->andReturn(false);
$auth->shouldReceive('user')->andReturn($user);

$hasher = m::mock(Hasher::class);
$hasher->shouldReceive('check')->andReturn(false);

$container = m::mock(Container::class);
$container->shouldReceive('make')->with('auth')->andReturn($auth);
$container->shouldReceive('make')->with('hash')->andReturn($hasher);

$trans = $this->getTranslator();
$trans->shouldReceive('get')->andReturnArg(0);

$v = new Validator($trans, ['password' => 'foo'], ['password' => 'password']);
$v->setContainer($container);

$this->assertFalse($v->passes());

// Succeeds when password is correct.
$user = m::mock(Authenticatable::class);
$user->shouldReceive('getAuthPassword');

$auth = m::mock(Guard::class);
$auth->shouldReceive('guard')->andReturn($auth);
$auth->shouldReceive('guest')->andReturn(false);
$auth->shouldReceive('user')->andReturn($user);

$hasher = m::mock(Hasher::class);
$hasher->shouldReceive('check')->andReturn(true);

$container = m::mock(Container::class);
$container->shouldReceive('make')->with('auth')->andReturn($auth);
$container->shouldReceive('make')->with('hash')->andReturn($hasher);

$trans = $this->getTranslator();
$trans->shouldReceive('get')->andReturnArg(0);

$v = new Validator($trans, ['password' => 'foo'], ['password' => 'password']);
$v->setContainer($container);

$this->assertTrue($v->passes());

// We can use a specific guard.
$user = m::mock(Authenticatable::class);
$user->shouldReceive('getAuthPassword');

$auth = m::mock(Guard::class);
$auth->shouldReceive('guard')->with('custom')->andReturn($auth);
$auth->shouldReceive('guest')->andReturn(false);
$auth->shouldReceive('user')->andReturn($user);

$hasher = m::mock(Hasher::class);
$hasher->shouldReceive('check')->andReturn(true);

$container = m::mock(Container::class);
$container->shouldReceive('make')->with('auth')->andReturn($auth);
$container->shouldReceive('make')->with('hash')->andReturn($hasher);

$trans = $this->getTranslator();
$trans->shouldReceive('get')->andReturnArg(0);

$v = new Validator($trans, ['password' => 'foo'], ['password' => 'password:custom']);
$v->setContainer($container);

$this->assertTrue($v->passes());
}

public function testValidatePresent()
{
$trans = $this->getIlluminateArrayTranslator();
Expand Down

0 comments on commit 1f54941

Please sign in to comment.