public function createAccountFromProviderDetails($details) { $entity = new UserEntity(); $entity->setName($details->name); $entity->setEmail($details->email); $entity->setUsername($details->nickname); $entity->setGithubUid($details->uid); return $this->userStorage->create($entity); }
public function createAction() { // If no POST - render if (!$this->is('post')) { return $this->render('UserModule:account:create.html.php'); } $missingFields = array(); $post = $this->post(); $requiredKeys = array('firstname', 'lastname', 'email', 'password'); // Check for missing fields, or fields being empty. foreach ($requiredKeys as $field) { if (!isset($post[$field]) || empty($post[$field])) { $missingFields[] = $field; } } // If any fields were missing, inform the client if (!empty($missingFields)) { return $this->render('UserModule:account:create.html.php', compact('missingFields')); } $accountHelper = $this->getService('user.account.helper'); // @todo - check email exists // Check if the user's email address already exists if ($accountHelper->existsByEmail($post['email'])) { return $this->createResponse(array('status' => 'error', 'code' => 'E_EMAIL_ALREADY_EXISTS')); } $userEntity = new \UserModule\Entity\User(); $userEntity->setEmail($post['email']); $userEntity->setFirstName($post['firstname']); $userEntity->setLastName($post['lastname']); $userEntity->setPassword($post['password']); $userEntity->setSalt(base64_encode(openssl_random_pseudo_bytes(16))); // Create the user $newUserID = $accountHelper->createUser($userEntity); // Insert an activation token for this user // $accountHelper->createUserActivation($userEntity); // Send the user's activation email // $this->sendActivationEmail($userEntity); }