public function login($firstName, $lastName, $dateOfBirth, $email, $gender, $fbId, $location = array(), $version, $container, $em) { $result = VTExceptionService::STATUS_INTERNAL_ERROR; // by default $user = $em->getRepository('ApiBundle:User')->findOneBy(array("fbId" => $fbId)); if (empty($user)) { $user = new User(); $user->setFirstName($firstName); $user->setLastName($lastName); $user->setEmail($email); $user->setGender($gender); $user->setBirthday(new \DateTime($dateOfBirth)); $user->setFbId($fbId); $em->persist($user); $em->flush(); return VTExceptionService::STATUS_OBJECT_CREATED; } else { return VTExceptionService::STATUS_OK; } return $result; }
public function addUserDataAction(Request $request) { $data = $request->request->all(); $em = $this->getDoctrine()->getManager(); $factory = $this->get('security.encoder_factory'); if (!empty($data)) { $salt = "cjezptqt56a20c64dc9ca"; $user = new User(); $user->setActive(1); $user->setEmail($data["email"]); $user->setFirstName($data["name"]); $user->setLastName($data["lastname"]); $user->setPhone($data["phone"]); $user->setRole($data["role"]); $encoder = $factory->getEncoder($user); $password = $encoder->encodePassword($data["password"], $salt); $user->setPassword($password); $user->setSalt($salt); $em->persist($user); $em->flush(); return "L'utilisateur a été ajouté avec success"; } return "l'utilisateur n'a pas pu être ajouter"; }