$userRepo = $em->getRepository('model\\entities\\User'); $roleRepo = $em->getRepository('model\\entities\\Role'); $authRepo = $em->getRepository('model\\entities\\Authentication'); $qlRepo = $em->getRepository('model\\entities\\QuickLogin'); $mail = new \utilities\SwiftMailLoader(); $password = isset($_POST['password']) ? $_POST['password'] : null; $vp = isset($_POST['vpass']) ? $_POST['vpass'] : null; $data['email'] = isset($_POST['email']) ? $_POST['email'] : null; $data['vemail'] = isset($_POST['vemail']) ? $_POST['vemail'] : null; $data['fname'] = isset($_POST['fname']) ? $_POST['fname'] : null; $data['lname'] = isset($_POST['lname']) ? $_POST['lname'] : null; if ($password == $vp && $data['email'] == $data['vemail'] && $password != null && $data['email'] != null) { if ($businessAuth->isIdentityFree($data['email'])) { //create user $user = new \model\entities\User(); $user->setFname($data['fname'])->setLname($data['lname']); $em->persist($user); $contact = new \model\entities\Contact(); $contact->setEmail($data['email'])->setUser($user); $em->persist($contact); $role = $roleRepo->find(2); $salt = $businessAuth->generateSalt(); $auth = new \model\entities\Authentication(); $auth->setIdentity($data['email'])->setPassword($businessAuth->createPassword($salt, $password))->setSalt($salt)->setUser($user)->setRole($role); $em->persist($auth); $ql = new \model\entities\QuickLogin(); $ql->setHash($businessQl->createHash($auth->getIdentity()))->setUser($user); $em->persist($ql); $em->flush(); $em->refresh($ql); $em->refresh($user);
throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'index.php?code=2'); } $data['pass'] = isset($_POST['pass']) ? $_POST['pass'] : null; $data['fname'] = isset($_POST['fname']) ? $_POST['fname'] : null; $data['lname'] = isset($_POST['lname']) ? $_POST['lname'] : null; $data['email'] = isset($_POST['email']) ? $_POST['email'] : null; $data['gender'] = isset($_POST['gender']) ? $_POST['gender'] : null; $data['phone'] = isset($_POST['phone']) ? $_POST['phone'] : null; $roleid = isset($_POST['rid']) ? $_POST['rid'] : 2; if (!$data['fname'] || !$data['lname'] || !$data['email'] || !$data['pass']) { array_shift($data); throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'account.php?a=addnew&code=2&' . http_build_query($data)); } else { if ($businessAuth->isIdentityFree($data['email'])) { $new = new \model\entities\User(); $newAuth = new \model\entities\Authentication(); $newContact = new \model\entities\Contact(); $role = $roleRepo->find($roleid); $new->setFname($data['fname'])->setLname($data['lname'])->setGender($data['gender']); $em->persist($new); $salt = $businessAuth->generateSalt(); $newAuth->setIdentity($data['email'])->setPassword($businessAuth->createPassword($salt, $data['pass']))->setSalt($salt)->setRole($role)->setUser($new); $newContact->setEmail($data['email'])->setPhone($data['phone'])->setUser($new); $em->persist($newAuth); $em->persist($newContact); $em->flush(); throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'users.php?code=1'); } else { throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'account.php?a=addnew&code=3&' . http_build_query($data)); } }