本文整理汇总了PHP中AppBundle\Entity\User::setPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setPassword方法的具体用法?PHP User::setPassword怎么用?PHP User::setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\User
的用法示例。
在下文中一共展示了User::setPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->user = new User();
$this->user->setUsername('test');
$this->user->setEmail('test@example.com');
$this->user->setPassword('test');
$this->log = new StressLog();
$this->log->setLocaltime(new \DateTime());
$this->log->setLevel(6);
$this->log->setUser($this->user);
}
示例2: load
public function load(ObjectManager $manager)
{
$userAdmin = new User();
$userAdmin->setFname('Ade');
$userAdmin->setLname('Arce');
$userAdmin->setEmail('ade@example.com.studionone');
$userAdmin->setPassword('password');
$userAdmin2 = new User();
$userAdmin2->setFname('Bob');
$userAdmin2->setLname('Brush');
$userAdmin2->setEmail('bob@example.com.studionone');
$userAdmin2->setPassword('password');
$userAdmin3 = new User();
$userAdmin3->setFname('Cat');
$userAdmin3->setLname('Capther');
$userAdmin3->setEmail('cat@example.com.studionone');
$userAdmin3->setPassword('password');
$manager->persist($userAdmin);
$manager->persist($userAdmin2);
$manager->persist($userAdmin3);
$manager->flush();
$this->addReference('user_one', $userAdmin);
$this->addReference('user_two', $userAdmin2);
$this->addReference('user_three', $userAdmin3);
}
示例3: loginAction
/**
* @Route("/admin-login", name="admin-login")
* @Template()
*/
public function loginAction()
{
// создание пользователя
$manager = $this->getDoctrine()->getManager();
$user = new User();
$user->setUsername('admin');
$user->setSalt(md5(time()));
$encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
$password = $encoder->encodePassword('admin', $user->getSalt());
$user->setPassword($password);
$user->setRoles('ROLE_OPERATOR');
$user->setLastName('admin');
$user->setFirstName('admin');
$user->setSurName('admin');
$user->setPhone('+79161111111');
//
$manager->persist($user);
$manager->flush($user);
if ($this->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $this->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $this->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
}
$pages = $this->getDoctrine()->getRepository('AppBundle:Page')->findAll();
return array('error' => $error, 'pages' => $pages);
}
示例4: encodePassword
private function encodePassword(User $user)
{
$plainPassword = $user->getPlainPassword();
if (!is_null($plainPassword)) {
$user->setPassword($this->passwordEncoder->encodePassword($user, $plainPassword));
}
}
示例5: load
public function load(ObjectManager $manager)
{
$users = array(array('name' => 'Gabe', 'lastName' => 'Newell', 'surName' => '', 'email' => 'admin@arkusnexus.com', 'password' => 'admin', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_ADMIN', 'image' => 'blog_newell1.jpg', 'positionId' => 1), array('name' => 'Kayla', 'lastName' => 'Person', 'surName' => '', 'email' => 'rh@arkusnexus.com', 'password' => 'rh', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_RH', 'image' => 'Kayla_Person-small.jpg', 'positionId' => 1), array('name' => 'Alejandro', 'lastName' => 'Hernandez', 'surName' => 'Marquez', 'email' => 'user1@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'MikePerson.jpg', 'positionId' => 1), array('name' => 'Bernardo', 'lastName' => 'Lemus', 'surName' => 'Ortiz', 'email' => 'user2@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'ralf-a.jpg', 'positionId' => 1), array('name' => 'Christian', 'lastName' => 'Flores', 'surName' => 'Filis', 'email' => 'user3@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'img_person.jpg', 'positionId' => 1), array('name' => 'David', 'lastName' => 'Acosta', 'surName' => 'Arellano', 'email' => 'user4@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'person3.jpg', 'positionId' => 1), array('name' => 'Eric', 'lastName' => 'Martinez', 'surName' => 'Ibarra', 'email' => 'user5@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => '3709.jpg', 'positionId' => 1), array('name' => 'Felipe', 'lastName' => 'Trejo', 'surName' => 'Contreras', 'email' => 'user6@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'people_with_arthritis.jpg', 'positionId' => 1), array('name' => 'Gerardo', 'lastName' => 'Garcia', 'surName' => 'Najera', 'email' => 'user7@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'img-02.jpg', 'positionId' => 1), array('name' => 'Hugo', 'lastName' => 'Ruiz', 'surName' => 'Sanchez', 'email' => 'user8@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'img-10.jpg', 'positionId' => 1), array('name' => 'Ignacio', 'lastName' => 'Corona', 'surName' => 'Silva', 'email' => 'user9@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'img-12.jpg', 'positionId' => 1), array('name' => 'Javier', 'lastName' => 'Reyes', 'surName' => 'Leon', 'email' => 'user10@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'img-13.jpg', 'positionId' => 1), array('name' => 'Karla', 'lastName' => 'Juarez', 'surName' => 'Mejia', 'email' => 'user11@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'images.jpg', 'positionId' => 1), array('name' => 'Lorenzo', 'lastName' => 'Escoto', 'surName' => 'Villalobos', 'email' => 'user12@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'img-21.jpg', 'positionId' => 1), array('name' => 'Steve', 'lastName' => 'Jobs', 'surName' => '', 'email' => 'user13@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'Jobs0212120.jpg', 'positionId' => 1), array('name' => 'Nestor', 'lastName' => 'Salinas', 'surName' => 'Morales', 'email' => 'user14@arkusnexus.com', 'password' => 'admin', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'person2.jpg', 'positionId' => 1), array('name' => 'Omar', 'lastName' => 'Torres', 'surName' => 'Zavaleta', 'email' => 'user15@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'person-detail.jpg', 'positionId' => 1), array('name' => 'Pedro', 'lastName' => 'Romero', 'surName' => 'Flores', 'email' => 'user16@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'poy_nomination_agassi.jpg', 'positionId' => 1), array('name' => 'Ruben', 'lastName' => 'Aceves', 'surName' => 'Nieto', 'email' => 'user17@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'person4.jpg', 'positionId' => 1), array('name' => 'Santiago', 'lastName' => 'Soriano', 'surName' => 'Aguilar', 'email' => 'user18@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'dan-misener-600_1.jpg', 'positionId' => 1), array('name' => 'Barack', 'lastName' => 'Obama', 'surName' => '', 'email' => 'user19@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'u-s-president-barack-obama.jpg', 'positionId' => 1), array('name' => 'Robin', 'lastName' => 'Williams', 'surName' => '', 'email' => 'user20@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'tumblr.jpg', 'positionId' => 1), array('name' => 'Bill', 'lastName' => 'Gates', 'surName' => '', 'email' => 'user21@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'bill-gates.jpg', 'positionId' => 1), array('name' => 'Kim', 'lastName' => 'Jong', 'surName' => 'Un', 'email' => 'user22@arkusnexus.com', 'password' => '1234', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'kwc.jpg', 'positionId' => 1), array('name' => 'Vladimir', 'lastName' => 'Putin', 'surName' => '', 'email' => 'user23@arkusnexus.com', 'password' => 'admin', 'admissionDate' => '12-12-12', 'roles' => 'ROLE_USER', 'image' => 'putinwink.jpg', 'positionId' => 1));
// Cuando se haga el 'seed' de Usuarios se pondran Roles por default
// Role : Colaborador
// $repository = $manager
// ->getRepository('AppBundle:Role');
// $roleEntity = $repository->find(1);
// Position : Software Developer
$repository = $manager->getRepository('AppBundle:Position');
$positionEntity = $repository->find(1);
// dump($roleentity);
// $roleentity = new Role();
// $roleentity->setName("ROL NO REAL");
// $positionentity = new Position();
// $positionentity->setName("POSICION NO REAL");
foreach ($users as $user) {
$entity = new User();
$entity->setName($user['name']);
$entity->setLastName($user['lastName']);
$entity->setSurName($user['surName']);
$entity->setUsername($user['email']);
$entity->setPassword($user['password']);
$entity->setAdmissionDate(new \DateTime("now"));
$entity->setImage($user['image']);
$entity->setRoles($user['roles']);
$entity->setPosition($positionEntity);
$manager->persist($entity);
}
$manager->flush();
}
示例6: createAction
public function createAction($format)
{
try {
$em = $this->getDoctrine()->getManager();
$user = new User();
$params = array();
$content = $this->get("request")->getContent();
if (!empty($content)) {
$params = json_decode($content, true);
$user->setConfirmationToken($params['confirmationToken']);
$user->setCredentialsExpireAt($params['credentialsExpireAt']);
$user->setCredentialsExpired($params['credentialsExpired']);
$user->setEmail($params['email']);
$user->setEmailCanonical($params['emailCanonical']);
$user->setEnabled($params['enabled']);
$user->setExpired($params['expired']);
$user->setExpiresAt($params['expiresAt']);
$user->setLastLogin($params['lastLogin']);
$user->setLocked($params['locked']);
$user->setPassword($params['password']);
$user->setPasswordRequestedAt($params['passwordRequestedAt']);
$user->setRoles($params['roles']);
$user->setSalt($params['salt']);
$user->setUsername($params['username']);
$user->setUsernameCanonical($params['usernameCanonical']);
}
$em->persist($user);
$em->flush();
return $this->formatResponse("ok", $format);
} catch (Exception $ex) {
return $this->formatResponse("error", $format);
}
}
示例7: load
public function load(ObjectManager $manager)
{
$password = "SecretPassword";
$user = new User();
$user->setUsername('rafael');
$user->setPassword($this->getEncoder($user)->encodePassword($password, $user->getSalt()));
$user->setName('Rafael');
$user->setEmail('rafael@example.com');
$manager->persist($user);
$user2 = new User();
$user2->setUsername('donatello');
$user2->setPassword($this->getEncoder($user2)->encodePassword($password, $user2->getSalt()));
$user2->setName('Donatello');
$user2->setEmail('donatello@example.com');
$manager->persist($user2);
$user3 = new User();
$user3->setUsername('michelangelo');
$user3->setPassword($this->getEncoder($user3)->encodePassword($password, $user3->getSalt()));
$user3->setName('Michelangelo');
$user3->setEmail('michelangelo@example.com');
$manager->persist($user3);
$user4 = new User();
$user4->setUsername('leonardo');
$user4->setPassword($this->getEncoder($user4)->encodePassword($password, $user4->getSalt()));
$user4->setName('Leonardo');
$user4->setEmail('leonardo@example.com');
$manager->persist($user4);
$manager->flush();
}
示例8: createUserAction
/**
* handles the creation of a new User
* @Route("/register/create", name="create_user")
*/
public function createUserAction()
{
$errorMessage = "";
$successMessage = "";
$defaultValues = ['username' => "", 'password' => "", 'passwordconfirm' => "", 'email' => ""];
// get POST request
$request = Request::createFromGlobals();
$username = $request->request->get('username');
$email = $request->request->get('email');
$password = $request->request->get('password');
$passwordconfirm = $request->request->get('passwordconfirm');
//checks what fields are blank
if (empty($username) || empty($email) || empty($password) || empty($passwordconfirm)) {
$errorMessage = "Sie müssen alle Felder ausfüllen!";
$defaultValues = ['username' => $username, 'password' => $password, 'passwordconfirm' => $passwordconfirm, 'email' => $email];
} elseif ($password !== $passwordconfirm) {
$errorMessage = "Die Passwörter müssen übereinstimmen!";
$defaultValues = ['username' => $username, 'password' => "", 'passwordconfirm' => "", 'email' => $email];
} else {
//writes the the new User in the Database
$user = new User();
$user->setUsername($username);
$user->setPassword(password_hash($password, PASSWORD_BCRYPT, array('cost' => 12)));
$user->setEmail($email);
$user->setRoles(array('ROLE_USER'));
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
$successMessage = "Benutzer wurde erfolgreich angelegt!";
}
return $this->render('AppBundle:Account:register.html.twig', array('errorMessage' => $errorMessage, 'successMessage' => $successMessage, 'defaultValues' => $defaultValues));
}
示例9: getUser
public function getUser($authorizationCode, UserProviderInterface $userProvider)
{
$provider = $this->getFacebookOAuthProvider();
try {
// the credentials are really the access token
$accessToken = $provider->getAccessToken('authorization_code', ['code' => $authorizationCode]);
} catch (IdentityProviderException $ex) {
$response = $e->getResponseBody();
$errorCode = $response['error']['code'];
$message = $response['error']['message'];
//var_dump($response);
//TODO throw a custom error to handle ???
}
$fbUser = $provider->getResourceOwner($accessToken);
$email = $fbUser->getEmail();
$em = $this->container->get('doctrine')->getManager();
$user = $em->getRepository('AppBundle:User')->findOneBy(['email' => $email]);
//If there is no user, we need to create one
if (!$user) {
$user = new User();
$user->setUsername($email);
$user->setEmail($email);
//Set to unencoded password.
//Since passwords are encode when checked, users should not be able to login using it
$user->setPassword('FACEBOOK LOGIN');
//Make sure that a user has at least the role of ROLE_USER when created
$roles = $user->getRoles();
$user->setRoles($roles);
}
$user->setFacebookId($fbUser->getId());
$em->persist($user);
$em->flush();
return $user;
}
示例10: addUserAction
/**
* @Route("/addUser/{uname}/{pswd}/{email}/{age}/{pic}/{phone}/{status}/{credit}")
*/
public function addUserAction($uname, $pswd, $email, $age, $pic, $phone, $status, $credit)
{
$response = new JsonResponse();
$res = $this->uniqAction($uname, $email, $phone, $credit);
if (empty($res)) {
$date = new \DateTime($age);
//$date->format('Y-m-d');
$user = new User();
$user->setName($uname);
$user->setNickName($uname);
$user->setPassword($pswd);
$user->setEmail($email);
$user->setBirthday($date);
$user->setPicpath($pic);
$user->setPhone($phone);
$user->setStatus($status);
$user->setCredit($credit);
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
//print_r($user);
$response->setData(array('response' => array('profile' => array(array("valid" => true)))));
} else {
$response->setData(array('response' => array('profile' => array($res))));
}
return $response;
}
示例11: createAnonymouslyAction
/**
* @Route("/record/anonymous", name="createRecordAnonymously")
* @Method("POST")
*/
public function createAnonymouslyAction(Request $request)
{
// user anonymous
$repository = $this->getDoctrine()->getRepository('AppBundle:User');
$count = $repository->count();
$username = 'Player' . dechex($count);
$password = chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90));
$user = new User();
$user->setUsername($username);
$user->setPassword(md5($password));
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
// record
$content = $request->getContent();
$response = json_decode($content, true);
if ($user != null) {
$record = new Record();
$record->setScore($response['score']);
$record->setUserId($user->getId());
$em = $this->getDoctrine()->getManager();
$em->persist($record);
$em->flush();
return new JsonResponse(['code' => 1, 'record' => ['id' => $record->getId(), 'score' => $record->getScore(), 'userId' => $record->getUserId()], 'user' => ['username' => $user->getUsername(), 'password' => $password]]);
} else {
return new JsonResponse(['code' => 0, 'message' => 'record not save']);
}
}
示例12: injectUser
protected function injectUser()
{
$this->user = new User();
//$admin = 'tester'; // MWAHAHAHA
//$departmentId = 5; // UiB
$role = $this->em->getRepository('AppBundle:Role')->findOneByRole('ROLE_USER');
$this->user->addRole($role);
$this->user->setGender(1);
$this->user->setFirstName("Shi");
$this->user->setLastName("LaLong");
$emd = $this->em->getRepository('AppBundle:FieldOfStudy')->find(40);
// Tuple "Andre" from UiB, id 40 for fos
$this->user->setFieldOfStudy($emd);
$this->user->setUserName("shiluib");
// Weird typo?
$this->user->setEmail("shiluib@student.uib.no");
$this->user->setPhone("47661674");
$this->user->setPicturePath("images/defaultProfile.png");
$this->user->setPassword("pimwrneil");
$createNewUserCode = bin2hex(openssl_random_pseudo_bytes(16));
$hashedNewUserCode = hash('sha512', $createNewUserCode, false);
$this->user->setNewUserCode($hashedNewUserCode);
// Persist the user
$this->user->setIsActive(1);
$this->em->persist($this->user);
$this->em->flush();
return $this;
}
示例13: createAction
/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function createAction()
{
$error = '';
$name = $this->getRequest()->request->get('_username');
$display_name = $this->getRequest()->request->get('_display_name');
$password = $this->getRequest()->request->get('_password');
// var_dump($password); die;
$roleId = 2;
$role = $this->getDoctrine()->getRepository('AppBundle:Role')->find($roleId);
//var_dump($role_id); die;
if ($this->_isUniqueUser($name)) {
$user = new User();
$user->setDisplayName($display_name);
$user->setName($name);
$user->setPassword($password);
$user->setRole($role);
$em = $this->getDoctrine()->getEntityManager();
$em->persist($user);
$em->flush();
return $this->render('AppBundle:Security:login.html.twig', array('name' => $name, 'error' => ''));
} else {
$error = "Користувач з іменем " . $name . ' уже існує. Будь оригінальний';
}
return $this->render("AppBundle:Film:index.html.twig", array('name' => $name, 'error' => $error));
}
示例14: registerAction
/**
* @Route("/register", name="register")
* @Template()
*/
public function registerAction(Request $request)
{
if ($request->getMethod() == 'POST') {
$manager = $this->getDoctrine()->getManager();
$user = new User();
$user->setUsername($request->request->get('username'));
$user->setSalt(md5(time()));
$encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
$password = $encoder->encodePassword($request->request->get('password'), $user->getSalt());
$user->setPassword($password);
$user->setRoles('ROLE_UNCONFIRMED');
$user->setLastName($request->request->get('lastName'));
$user->setFirstName($request->request->get('firstName'));
$user->setSurName('');
$user->setPhone($request->request->get('phone'));
$user->setCompany($request->request->get('companyTitle'));
$manager->persist($user);
$manager->flush($user);
$manager->refresh($user);
$session = new Session();
$session->getFlashBag()->add('success', 'Ваша заявка принята. Пожалуйста, ожидайте подтверждения регистрации на указанный электронный адрес');
@$this->get('email.service')->send(array($user->getUsername()), array('AppBundle:Email:registerNotifyUser.html.twig'), 'Сообщение от navigator mediaFirst');
@$this->get('email.service')->send(array('tulupov.m@gmail.com', 'ryabova.t@mediafirst.ru', 'kravtsova.m@mediafirst.ru'), array('AppBundle:Email:registerNotify.html.twig'), 'Сообщение от navigator mediaFirst');
return $this->redirect($this->generateUrl('homepage'));
}
return array();
}
示例15: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$userAdmin = new User();
$userAdmin->setUsername('admin');
$userAdmin->setPassword('test');
$manager->persist($userAdmin);
$manager->flush();
}