PHP code example of kaystrobach / password
1. Go to this page and download the library: Download kaystrobach/password library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kaystrobach / password example snippets
/**
* @Flow\Inject()
* @var HashService
*/
protected $hashService;
/**
* @Flow\Inject()
* @var AccountRepository
*/
protected $accountRepository;
/**
* @param array $newPassword
* @throws StopActionException
*
* @Flow\Validate(argumentName="newPassword", type="KayStrobach\Password\Validation\Validator\PasswordValidator", options={"minimumChars":6, "accountIdentifierNotContained":1, "partyNameNotContained":1})
*/
public function changePasswordAction($newPassword) {
$account->setCredentialsSource($this->hashService->hashPassword($plainPassword, 'default'));
if($this->persistenceManager->isNewObject($account)) {
$this->accountRepository->add($account);
} else {
$this->accountRepository->update($account);
}
$this->addFlashMessage('Password changed');
$this->redirect('index');
}