public function setRandomPassword($username)
    {
        $password = false;

        /** @var UsersRepository $repo */
        $repo = $this->em->getRepository(Entity\Users::class);
        if ($userEntity = $repo->getUser($username)) {
            $password = $this->app['randomgenerator']->generateString(12);

            $userEntity->setPassword($password);
            $userEntity->setShadowpassword(null);
            $userEntity->setShadowtoken(null);
            $userEntity->setShadowvalidity(null);

            $this->em->getRepository(Entity\Users::class)->save($userEntity);

            $this->app['logger.system']->info(
                "Password for user '{$userEntity->getUsername()}' was reset via Nut.",
                ['event' => 'authentication']
            );
        }

        return $password;
    }
public function setRandomPassword($username)
    {
        $password = false;

        /** @var UsersRepository $repo */
        $repo = $this->em->getRepository(Entity\Users::class);
        if ($userEntity = $repo->getUser($username)) {
            $password = $this->app['randomgenerator']->generateString(12);

            $userEntity->setPassword($password);
            $userEntity->setShadowpassword(null);
            $userEntity->setShadowtoken(null);
            $userEntity->setShadowvalidity(null);

            $this->em->getRepository(Entity\Users::class)->save($userEntity);

            $this->app['logger.system']->info(
                "Password for user '{$userEntity->getUsername()}' was reset via Nut.",
                ['event' => 'authentication']
            );
        }

        return $password;
    }
public function setRandomPassword ( $ username ) { $ password = false ; /** @var UsersRepository $repo */ $ repo = $ this -> em -> getRepository ( Entity \ Users :: class ) ; if ( $ userEntity = $ repo -> getUser ( $ username ) ) { $ password = $ this -> app [ 'randomgenerator' ] -> generateString ( 12 ) ; $ userEntity -> setPassword ( $ password ) ; $ userEntity -> setShadowpassword ( null ) ; $ userEntity -> setShadowtoken ( null ) ; $ userEntity -> setShadowvalidity ( null ) ; $ this -> em -> getRepository ( Entity \ Users :: class ) -> save ( $ userEntity ) ; $ this -> app [ 'logger.system' ] -> info ( "Password for user '{$userEntity->getUsername()}' was reset via Nut." , [ 'event' => 'authentication' ] ) ; } return $ password ; }
Set a random password for user.

@param string $username user specified by ID, username or email address

@return string|bool new password or FALSE when no match for username
Set a random password for user .