/**
  * Convert an associative array to an object user
  *
  * @param array $data the associative array
  *
  * @return \Entity\User the object user
  */
 protected function convertArrayToObject(array $data)
 {
     $user = new User();
     $user->setId($data['id']);
     $user->setUsername($data['username']);
     $user->setPassword($data['password']);
     return $user;
 }
 function create_user($row)
 {
     $user = new User();
     $user->setUsername($row['username']);
     $user->setPassword($row['password']);
     $user->setRole($row['role']);
     return $user;
 }
 public function createAdmin($email, $username, $password, $roles, $lastName = '', $firstName = '')
 {
     $user = new User();
     $user->setEmail($email);
     $user->setEnabled(0);
     $user->setUsername($username);
     $user->setSubscribe(new \DateTime('now'));
     $user->setRoles(serialize($roles));
     $user->setLastName($lastName);
     $user->setFirstName($firstName);
     $salt = uniqid(mt_rand(), true);
     $options = ['cost' => 11, 'salt' => $salt];
     $user->setSalt($salt);
     $user->setPassword(password_hash($password, PASSWORD_BCRYPT, $options));
     $this->em->persist($user);
     $this->em->flush();
 }
 public function registerUser(Request $request)
 {
     $sessionUserData = $this->app['session'];
     $entityManager = $this->app['doctrine'];
     $user = new User();
     $user->setUserName($request->request->get('userName'));
     $user->setUserEmail($request->request->get('userEmail'));
     $user->setPassword($request->request->get('userPassword'));
     $user->setOfficeLocation($request->request->get('officeLocation'));
     $user->setUserAddress($request->request->get('userAddress'));
     try {
         $entityManager->persist($user);
         $entityManager->flush();
         if (null !== $request->files->get('resumeFile')) {
             $fs = new FileHandler();
             $fs->fileUpload($request->files->get('resumeFile'), $user->getId(), UPLOAD_PATH);
         }
         $sessionUserData->getFlashBag()->add('alert_success', 'Registration successful');
         return $this->app->redirect(BASEPATH . "/login");
     } catch (UniqueConstraintViolationException $ex) {
         $sessionUserData->getFlashBag()->add('alert_danger', 'Sorry, this email id is already registered!');
         return $this->app->redirect(BASEPATH . "/register");
     }
 }
 public function setPassword($password)
 {
     $this->__load();
     return parent::setPassword($password);
 }
 /**
  * {@inheritDoc}
  */
 public function setPassword($password)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPassword', [$password]);
     return parent::setPassword($password);
 }
Example #7
0
 /**
  * Encode a plain text password and set it on the given User object.
  *
  * @param User $user
  * @param string $password A plain text password.
  */
 public function setUserPassword(User $user, $password)
 {
     return $user->setPassword($this->encodeUserPassword($user, $password));
 }
Example #8
0
require_once 'before.php';
use Entity\User;
$pagename = "Registration";
$useremail = "";
$userpassword = "";
$userdescription = "";
$userfirstname = "";
$userlastname = "";
$userdate = "";
if (isset($_POST['UserEmail']) && isset($_POST['UserPassword']) && isset($_POST['UserDescription']) && isset($_POST['UserFirstname']) && isset($_POST['UserLastname']) && isset($_POST['UserDate'])) {
    if (!$userLoggedIn) {
        //add user registration and handle errors
        $newuser = new User();
        $newuser->setEmail(htmlentities($_POST['UserEmail']));
        $newuser->setPassword(htmlentities($_POST['UserPassword']));
        $newuser->setDescription(htmlentities($_POST['UserDescription']));
        $newuser->setFirstname(htmlentities($_POST['UserFirstname']));
        $newuser->setLastname(htmlentities($_POST['UserLastname']));
        $date = DateTime::createFromFormat('Y-m-d', $_POST['UserDate']);
        $newuser->setBirthDate($date);
        $em->persist($newuser);
        $em->flush($newuser);
        $_SESSION['success'] = "You have been registered";
        header('Location: threads.php');
    } else {
        $_SESSION['success'] = "You are logged in.";
        header('Location: threads.php');
    }
} else {
    include '../src/Views/Header.php';