Beispiel #1
0
 public function testEncodePasswordReturnsUsedUserClass()
 {
     $userManager = new UserManager($this->encoderFactoryMock, CustomUser::class);
     $encoded = $userManager->encodePassword('pass');
     $this->assertArrayHasKey('user', $encoded);
     $this->assertEquals(CustomUser::class, $encoded['user']);
 }
 /**
  * {@InheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $password = $input->getArgument('password');
     $salt = $input->getOption('salt');
     $userClass = $input->getOption('userclass');
     $user = null;
     if (null !== $userClass) {
         if (!class_exists($userClass)) {
             $output->writeln('Please provide a valid user class with namespace.');
             $output->writeln('Class "' . $userClass . '" does not exists.');
             return false;
         }
         $user = new $userClass();
     }
     $encoded = $this->userManager->encodePassword($password, $user, $salt);
     $output->writeln('Clear password: '******'User class:     ' . $encoded['user']);
     $output->writeln('Salt used:      ' . $encoded['salt']);
     $output->writeln('Generated hash: ' . $encoded['hash']);
 }