Neos.Neos/Classes/Domain/Service/UserService.php
public function setUserPassword(User $user, $password)
    {
        $tokens = $this->authenticationManager->getTokens();
        $indexedTokens = [];
        foreach ($tokens as $token) {
            /** @var TokenInterface $token */
            $indexedTokens[$token->getAuthenticationProviderName()] = $token;
        }

        foreach ($user->getAccounts() as $account) {
            /** @var Account $account */
            $authenticationProviderName = $account->getAuthenticationProviderName();
            if (isset($indexedTokens[$authenticationProviderName]) && $indexedTokens[$authenticationProviderName] instanceof UsernamePassword) {
                $account->setCredentialsSource($this->hashService->hashPassword($password));
                $this->accountRepository->update($account);
            }
        }
    }
public function setUserPassword(User $user, $password)
    {
        $tokens = $this->authenticationManager->getTokens();
        $indexedTokens = [];
        foreach ($tokens as $token) {
            /** @var TokenInterface $token */
            $indexedTokens[$token->getAuthenticationProviderName()] = $token;
        }

        foreach ($user->getAccounts() as $account) {
            /** @var Account $account */
            $authenticationProviderName = $account->getAuthenticationProviderName();
            if (isset($indexedTokens[$authenticationProviderName]) && $indexedTokens[$authenticationProviderName] instanceof UsernamePassword) {
                $account->setCredentialsSource($this->hashService->hashPassword($password));
                $this->accountRepository->update($account);
            }
        }
    }
public function setUserPassword ( User $ user , $ password ) { $ tokens = $ this -> authenticationManager -> getTokens ( ) ; $ indexedTokens = [ ] ; foreach ( $ tokens as $ token ) { /** @var TokenInterface $token */ $ indexedTokens [ $ token -> getAuthenticationProviderName ( ) ] = $ token ; } foreach ( $ user -> getAccounts ( ) as $ account ) { /** @var Account $account */ $ authenticationProviderName = $ account -> getAuthenticationProviderName ( ) ; if ( isset ( $ indexedTokens [ $ authenticationProviderName ] ) && $ indexedTokens [ $ authenticationProviderName ] instanceof UsernamePassword ) { $ account -> setCredentialsSource ( $ this -> hashService -> hashPassword ( $ password ) ) ; $ this -> accountRepository -> update ( $ account ) ; } } }
Sets a new password for the given user

This method will iterate over all accounts owned by the given user and, if the account uses a UsernamePasswordToken,
sets a new password accordingly.

@param User $user The user to set the password for
@param string $password A new password
@return void
@api
Sets a new password for the given user