/** * Create User on the Command Line * * @param string $username The email address, which also serves as the username. * @param string $password This user's password. * @param string $additionalAttributes Additional attributes to pass to the registrationFlow as semicolon-separated list. Example: ./flow sandstormuser:create ... --additionalAttributes="customerType:CUSTOMER;color:blue" */ public function createCommand($username, $password, $additionalAttributes = '') { // Parse additionalAttributes if they exist $attributes = []; if (strlen($additionalAttributes) > 0) { $attributesSplitBySeparator = explode(';', $additionalAttributes); array_map(function ($singleAttribute) use(&$attributes) { $splitAttribute = explode(':', $singleAttribute); $attributes[$splitAttribute[0]] = $splitAttribute[1]; }, $attributesSplitBySeparator); } $passwordDto = new PasswordDto(); $passwordDto->setPassword($password); $passwordDto->setPasswordConfirmation($password); $registrationFlow = new RegistrationFlow(); $registrationFlow->setPasswordDto($passwordDto); $registrationFlow->setEmail($username); $registrationFlow->setAttributes($attributes); // Remove existing registration flows $alreadyExistingFlows = $this->registrationFlowRepository->findByEmail($registrationFlow->getEmail()); if (count($alreadyExistingFlows) > 0) { foreach ($alreadyExistingFlows as $alreadyExistingFlow) { $this->registrationFlowRepository->remove($alreadyExistingFlow); } } $registrationFlow->storeEncryptedPassword(); // Store the RF and persist so the activate command will find it $this->registrationFlowRepository->add($registrationFlow); $this->persistenceManager->persistAll(); // Directly activate the account $this->activateRegistrationCommand($username); $this->outputLine('Added the User <b>"%s"</b> with password <b>"%s"</b>.', [$username, $password]); }
public function getEncryptedPassword() { return $this->passwordDto->getEncryptedPasswordAndRemoveNonencryptedVersion(); }
/** * @param PasswordDto $value The value that should be validated * @return void * @throws InvalidValidationOptionsException */ protected function isValid($value) { if (!$value->arePasswordsEqual()) { $this->result->forProperty('password')->addError(new Error('Passwords do not match.', 1464086581)); } }
public function storeEncryptedPassword() { $this->encryptedPassword = $this->passwordDto->getEncryptedPasswordAndRemoveNonencryptedVersion(); }