Skip to content

Commit d6fd27c

Browse files
authored
Remove password rule (#39030)
1 parent 12d6652 commit d6fd27c

File tree

2 files changed

+0
-107
lines changed

2 files changed

+0
-107
lines changed

src/Illuminate/Validation/Concerns/ValidatesAttributes.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,19 +1369,6 @@ public function validateNumeric($attribute, $value)
13691369
return is_numeric($value);
13701370
}
13711371

1372-
/**
1373-
* Validate that the password of the currently authenticated user matches the given value.
1374-
*
1375-
* @param string $attribute
1376-
* @param mixed $value
1377-
* @param array $parameters
1378-
* @return bool
1379-
*/
1380-
protected function validatePassword($attribute, $value, $parameters)
1381-
{
1382-
return $this->validateCurrentPassword($attribute, $value, $parameters);
1383-
}
1384-
13851372
/**
13861373
* Validate that an attribute exists even if not filled.
13871374
*

tests/Validation/ValidationValidatorTest.php

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -880,100 +880,6 @@ public function testValidationStopsAtFailedPresenceCheck()
880880
$this->assertEquals(['validation.present'], $v->errors()->get('name'));
881881
}
882882

883-
public function testValidatePassword()
884-
{
885-
// Fails when user is not logged in.
886-
$auth = m::mock(Guard::class);
887-
$auth->shouldReceive('guard')->andReturn($auth);
888-
$auth->shouldReceive('guest')->andReturn(true);
889-
890-
$hasher = m::mock(Hasher::class);
891-
892-
$container = m::mock(Container::class);
893-
$container->shouldReceive('make')->with('auth')->andReturn($auth);
894-
$container->shouldReceive('make')->with('hash')->andReturn($hasher);
895-
896-
$trans = $this->getTranslator();
897-
$trans->shouldReceive('get')->andReturnArg(0);
898-
899-
$v = new Validator($trans, ['password' => 'foo'], ['password' => 'password']);
900-
$v->setContainer($container);
901-
902-
$this->assertFalse($v->passes());
903-
904-
// Fails when password is incorrect.
905-
$user = m::mock(Authenticatable::class);
906-
$user->shouldReceive('getAuthPassword');
907-
908-
$auth = m::mock(Guard::class);
909-
$auth->shouldReceive('guard')->andReturn($auth);
910-
$auth->shouldReceive('guest')->andReturn(false);
911-
$auth->shouldReceive('user')->andReturn($user);
912-
913-
$hasher = m::mock(Hasher::class);
914-
$hasher->shouldReceive('check')->andReturn(false);
915-
916-
$container = m::mock(Container::class);
917-
$container->shouldReceive('make')->with('auth')->andReturn($auth);
918-
$container->shouldReceive('make')->with('hash')->andReturn($hasher);
919-
920-
$trans = $this->getTranslator();
921-
$trans->shouldReceive('get')->andReturnArg(0);
922-
923-
$v = new Validator($trans, ['password' => 'foo'], ['password' => 'password']);
924-
$v->setContainer($container);
925-
926-
$this->assertFalse($v->passes());
927-
928-
// Succeeds when password is correct.
929-
$user = m::mock(Authenticatable::class);
930-
$user->shouldReceive('getAuthPassword');
931-
932-
$auth = m::mock(Guard::class);
933-
$auth->shouldReceive('guard')->andReturn($auth);
934-
$auth->shouldReceive('guest')->andReturn(false);
935-
$auth->shouldReceive('user')->andReturn($user);
936-
937-
$hasher = m::mock(Hasher::class);
938-
$hasher->shouldReceive('check')->andReturn(true);
939-
940-
$container = m::mock(Container::class);
941-
$container->shouldReceive('make')->with('auth')->andReturn($auth);
942-
$container->shouldReceive('make')->with('hash')->andReturn($hasher);
943-
944-
$trans = $this->getTranslator();
945-
$trans->shouldReceive('get')->andReturnArg(0);
946-
947-
$v = new Validator($trans, ['password' => 'foo'], ['password' => 'password']);
948-
$v->setContainer($container);
949-
950-
$this->assertTrue($v->passes());
951-
952-
// We can use a specific guard.
953-
$user = m::mock(Authenticatable::class);
954-
$user->shouldReceive('getAuthPassword');
955-
956-
$auth = m::mock(Guard::class);
957-
$auth->shouldReceive('guard')->with('custom')->andReturn($auth);
958-
$auth->shouldReceive('guest')->andReturn(false);
959-
$auth->shouldReceive('user')->andReturn($user);
960-
961-
$hasher = m::mock(Hasher::class);
962-
$hasher->shouldReceive('check')->andReturn(true);
963-
964-
$container = m::mock(Container::class);
965-
$container->shouldReceive('make')->with('auth')->andReturn($auth);
966-
$container->shouldReceive('make')->with('hash')->andReturn($hasher);
967-
968-
$trans = $this->getTranslator();
969-
$trans->shouldReceive('get')->andReturnArg(0);
970-
971-
$v = new Validator($trans, ['password' => 'foo'], ['password' => 'password:custom']);
972-
$v->setContainer($container);
973-
974-
$this->assertTrue($v->passes());
975-
}
976-
977883
public function testValidatePresent()
978884
{
979885
$trans = $this->getIlluminateArrayTranslator();

0 commit comments

Comments
 (0)