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("*****@*****.**"); $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; }
public function testSetGender() { // new entity $user = new User(); // Use the setGender method $user->setGender("0"); // Assert the result $this->assertEquals("0", $user->getGender()); }
public function load(ObjectManager $manager) { $u1 = new User(); $u1->setUsername('admin'); $u1->setGender(1); $u1->setEmail("*****@*****.**"); $u1->setCreationDate(new \DateTime('now')); $u1->setModificationDate(new \DateTime('now')); $manager->persist($u1); $manager->flush(); }
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(); $facebookId = $fbUser->getId(); $gender = $fbUser->getGender(); $firstname = $fbUser->getFirstName(); $lastname = $fbUser->getLastname(); $locale = $fbUser->getLocale(); $name = $fbUser->getName(); $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); $user->setGender($gender); $user->setFirstname($firstname); $user->setLastname($lastname); $user->setLocale($locale); $user->setFacebookName($name); //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->setLastLogin(new \DateTime()); $user->setFacebookId($facebookId); $em->persist($user); $em->flush(); return $user; }
public function load(ObjectManager $manager) { $u1 = new User(); $u1->setUsername('admin'); $u1->setGender(1); $u1->setEmail("*****@*****.**"); $u1->setCreationDate(new \DateTime('now')); $u1->setModificationDate(new \DateTime('now')); $t1 = new Topic(); $t1->setTitle('first topic'); $t1->setAnthorId(1); $t1->setAgree(1); $t1->setDisagree(0); $t1->setContent('long long long string'); $t1->setModificationDate(new \DateTime('now')); $t1->setCreationDate(new \DateTime('now')); $manager->persist($u1); $manager->persist($t1); $manager->flush(); }
public function installUsers() { $maleNames = array("Maaiz Rahim", "Aayid Akram", "Salaah Fadel", "Raadi Zaman", "Yahya Morad", "Sirajuddeen Sultan", "Saleem Yusuf", "Salaah Hoque", "Maaiz Jafari", "Mushtaaq Sultan", "Anwar Shahidi", "Awni Ameen", "Jawaad Barakat", "Mamoon Bari", "Hibbaan Baten", "Abdul Baasid Ali", "Abdul Ghafoor Kazemi", "Bishr Shehata", "Mujahid Rahaim", "Badraan Abdullah", "Anwar Shahidi", "Awni Ameen", "Jawaad Barakat", "Mamoon Bari", "Hibbaan Baten", "Abdul Baasid Ali", "Abdul Ghafoor Kazemi", "Bishr Shehata", "Mujahid Rahaim", "Badraan Abdullah", "Shuraih Daoud", "Aiman Sabet", "Sad Kamara", "Munsif Hamidi", "Usaama Hamed", "Abdur Raqeeb Can", "Muaaid Haider", "Arkaan Afzal", "Ashqar Hashem", "Ammaar Rasul"); $femaleNames = array("Nahla Fahmy", "Umaima Rayes", "Zuhra Jabbour", "Laaiqa Naderi", "Sitaara Hashmi", "Awda Ozer", "Sulama Afzal", "Sanad Mahmood", "Maimoona Amara", "Nuha Neman", "Mahdeeya Khan", "Tareefa Salman", "Rumaana Hadi", "Qaaida Tariq", "Wasmaaa Dada", "Kinaana Barakat", "Hadiyya Mahdi", "Majeeda Mohammed", "Hameeda Younan", "Kawkab Vaziri", "Labeeba Hamad", "Tahaani Farhat", "Zumruda Hussain", "Nadheera Koroma", "Suhaa Naim", "Reema Shah", "Saajida Samaan", "Ameera Jamail", "Almaasa Adel", "Shamaail Fahs", "Qamraaa Sadri", "Nuzha Ghazal", "Tamanna Azimi", "Fareeda Kanan", "Hamaama Gaber", "Majeeda Hamidi", "Nabeeha Suleiman", "Manaara Khalil", "Saaliha Abraham", "Faraah Hammad"); for ($i = 0; $i < 100; $i++) { $user = new User(); if ($i % 2 == 0) { $male = "male"; $name = $maleNames[rand(0, 6)]; $img = $this->getImage("men"); } else { $male = "female"; $names = $femaleNames[rand(0, 6)]; $img = $this->getImage("women"); } $username = str_replace(' ', '', $name); $mail = $username . "@gmail.com"; $num = "658806711"; $user->setUsername($username . rand(1, 50000)); $user->setFullName($name); $user->setEmail($mail); $user->setNumber($num); $days = rand(10, 40) * 365 + rand(1, 400); $str = $days . " days ago"; $user->setDob(new \DateTime($str)); $user->setPassword("pass"); $user->setGender($male); $user->setPicture($img); $em = $this->getDoctrine()->getManager(); $factory = $this->get('security.encoder_factory'); $encoder = $factory->getEncoder($user); $password = $encoder->encodePassword($user->getPassword(), $user->getSalt()); $user->setPassword($password); $em->persist($user); $em->flush(); } }
public function load(ObjectManager $manager) { $user1 = new User(); $user1->setIsActive('1'); $user1->setEmail('*****@*****.**'); $user1->setFirstName('Petter'); $user1->setLastName('Johansen'); $user1->setGender('0'); $user1->setPhone('95347865'); $user1->setUserName('petjo'); $user1->setPassword('1234'); $user1->addRole($this->getReference('role-4')); $user1->setFieldOfStudy($this->getReference('fos-1')); $user1->setPicturePath('images/defaultProfile.png'); $manager->persist($user1); $user2 = new User(); $user2->setIsActive('1'); $user2->setEmail('*****@*****.**'); $user2->setFirstName('Ida'); $user2->setLastName('Andreassen'); $user2->setGender('1'); $user2->setPhone('95267841'); $user2->setUserName('idaan'); $user2->setPassword('1234'); $user2->addRole($this->getReference('role-1')); $user2->setFieldOfStudy($this->getReference('fos-2')); $user2->setPicturePath('images/defaultProfile.png'); $manager->persist($user2); $user3 = new User(); $user3->setIsActive('1'); $user3->setEmail('*****@*****.**'); $user3->setFirstName('Kristoffer'); $user3->setLastName('Bø'); $user3->setGender('0'); $user3->setPhone('95148725'); $user3->setUserName('kribo'); $user3->setPassword('1234'); $user3->addRole($this->getReference('role-1')); $user3->setFieldOfStudy($this->getReference('fos-3')); $user3->setPicturePath('images/defaultProfile.png'); $manager->persist($user3); $user4 = new User(); $user4->setIsActive('1'); $user4->setEmail('*****@*****.**'); $user4->setFirstName('Thomas'); $user4->setLastName('Alm'); $user4->setGender('0'); $user4->setPhone('12312312'); $user4->setUserName('thomas'); $user4->setPassword('123'); $user4->addRole($this->getReference('role-1')); $user4->setFieldOfStudy($this->getReference('fos-1')); $user4->setPicturePath('images/defaultProfile.png'); $manager->persist($user4); $user5 = new User(); $user5->setIsActive('1'); $user5->setEmail('a@b.c'); $user5->setFirstName('Reidun'); $user5->setLastName('Persdatter Ødegaard'); $user5->setGender('1'); $user5->setPhone('92269548'); $user5->setUserName('reidun'); $user5->setPassword('123'); $user5->addRole($this->getReference('role-4')); $user5->setFieldOfStudy($this->getReference('fos-1')); $user5->setPicturePath('images/defaultProfile.png'); $manager->persist($user5); $user6 = new User(); $user6->setIsActive('1'); $user6->setEmail('b@b.c'); $user6->setFirstName('Siri'); $user6->setLastName('Brenna Eskeland'); $user6->setGender('1'); $user6->setPhone('99540025'); $user6->setUserName('siri'); $user6->setPassword('123'); $user6->addRole($this->getReference('role-4')); $user6->setFieldOfStudy($this->getReference('fos-1')); $user6->setPicturePath('images/defaultProfile.png'); $manager->persist($user6); $user7 = new User(); $user7->setIsActive('1'); $user7->setEmail('c@b.c'); $user7->setFirstName('Eirik'); $user7->setLastName('Myrvoll-Nilsen'); $user7->setGender('0'); $user7->setPhone('93093824'); $user7->setUserName('eirik'); $user7->setPassword('123'); $user7->addRole($this->getReference('role-2')); $user7->setFieldOfStudy($this->getReference('fos-1')); $user7->setPicturePath('images/defaultProfile.png'); $manager->persist($user7); $user8 = new User(); $user8->setIsActive('1'); $user8->setEmail('d@b.c'); $user8->setFirstName('Ruben'); $user8->setLastName('Ravnå'); $user8->setGender('0'); $user8->setPhone('98059155'); $user8->setUserName('ruben'); $user8->setPassword('123'); $user8->addRole($this->getReference('role-4')); $user8->setFieldOfStudy($this->getReference('fos-1')); $user8->setPicturePath('images/defaultProfile.png'); $manager->persist($user8); $user9 = new User(); $user9->setIsActive('1'); $user9->setEmail('e@b.c'); $user9->setFirstName('Liv'); $user9->setLastName('Rasdal Håland'); $user9->setGender('1'); $user9->setPhone('45506381'); $user9->setUserName('liv'); $user9->setPassword('123'); $user9->addRole($this->getReference('role-2')); $user9->setFieldOfStudy($this->getReference('fos-1')); $user9->setPicturePath('images/defaultProfile.png'); $manager->persist($user9); $user10 = new User(); $user10->setIsActive('1'); $user10->setEmail('f@b.c'); $user10->setFirstName('Johannes'); $user10->setLastName('Bogen'); $user10->setGender('0'); $user10->setPhone('95480124'); $user10->setUserName('johannes'); $user10->setPassword('123'); $user10->addRole($this->getReference('role-2')); $user10->setFieldOfStudy($this->getReference('fos-1')); $user10->setPicturePath('images/defaultProfile.png'); $manager->persist($user10); $user11 = new User(); $user11->setIsActive('1'); $user11->setEmail('g@b.c'); $user11->setFirstName('Cecilie'); $user11->setLastName('Teisberg'); $user11->setGender('1'); $user11->setPhone('45688060'); $user11->setUserName('cecilie'); $user11->setPassword('123'); $user11->addRole($this->getReference('role-2')); $user11->setFieldOfStudy($this->getReference('fos-1')); $user11->setPicturePath('images/defaultProfile.png'); $manager->persist($user11); $user12 = new User(); $user12->setIsActive('1'); $user12->setEmail('h@b.c'); $user12->setFirstName('Håkon'); $user12->setLastName('Nøstvik'); $user12->setGender('0'); $user12->setPhone('99413718'); $user12->setUserName('haakon'); $user12->setPassword('123'); $user12->addRole($this->getReference('role-2')); $user12->setFieldOfStudy($this->getReference('fos-1')); $user12->setPicturePath('images/defaultProfile.png'); $manager->persist($user12); $user13 = new User(); $user13->setIsActive('1'); $user13->setEmail('i@b.c'); $user13->setFirstName('Maulisha'); $user13->setLastName('Thavarajan'); $user13->setGender('1'); $user13->setPhone('45439367'); $user13->setUserName('maulisha'); $user13->setPassword('123'); $user13->addRole($this->getReference('role-2')); $user13->setFieldOfStudy($this->getReference('fos-1')); $user13->setPicturePath('images/defaultProfile.png'); $manager->persist($user13); $user = new User(); $user->setIsActive('1'); $user->setEmail('j@b.c'); $user->setFirstName('Marte'); $user->setLastName('Saghagen'); $user->setGender('1'); $user->setPhone('97623818'); $user->setUserName('marte'); $user->setPassword('123'); $user->addRole($this->getReference('role-2')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('k@b.c'); $user->setFirstName('Angela'); $user->setLastName('Maiken Johnsen'); $user->setGender('1'); $user->setPhone('91152489'); $user->setUserName('angela'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('l@b.c'); $user->setFirstName('Ingrid'); $user->setLastName('Seip Domben'); $user->setGender('1'); $user->setPhone('91104644'); $user->setUserName('ingrid'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('m@b.c'); $user->setFirstName('Bjørnar'); $user->setLastName('Askeland Flatøe'); $user->setGender('0'); $user->setPhone('97063217'); $user->setUserName('bjoernar'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('n@b.c'); $user->setFirstName('Stig-Martin'); $user->setLastName('Liavåg'); $user->setGender('0'); $user->setPhone('99119941'); $user->setUserName('stig'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('o@b.c'); $user->setFirstName('Rune'); $user->setLastName('Nordmo'); $user->setGender('0'); $user->setPhone('11000000'); $user->setUserName('rune'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('p@b.c'); $user->setFirstName('Christopher'); $user->setLastName('Schwartz Kvarme'); $user->setGender('0'); $user->setPhone('91383316'); $user->setUserName('chris'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('q@b.c'); $user->setFirstName('Anna'); $user->setLastName('Madeleine Goldsack'); $user->setGender('1'); $user->setPhone('98896056'); $user->setUserName('anna'); $user->setPassword('123'); $user->addRole($this->getReference('role-2')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('r@b.c'); $user->setFirstName('Anna'); $user->setLastName('Kristine Auråen'); $user->setGender('1'); $user->setPhone('48265325'); $user->setUserName('annak'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('s@b.c'); $user->setFirstName('Hilde'); $user->setLastName('Schjerven Magnø'); $user->setGender('1'); $user->setPhone('47259291'); $user->setUserName('hilde'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('t@b.c'); $user->setFirstName('Henrik'); $user->setLastName('Finsrud'); $user->setGender('0'); $user->setPhone('45852380'); $user->setUserName('henrik'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('u@b.c'); $user->setFirstName('Aleksander'); $user->setLastName('Tryggan'); $user->setGender('0'); $user->setPhone('99321289'); $user->setUserName('aleksander'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('v@b.c'); $user->setFirstName('Thinius'); $user->setLastName('Alexander Rosé'); $user->setGender('0'); $user->setPhone('95119929'); $user->setUserName('thinius'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('w@b.c'); $user->setFirstName('Petter'); $user->setLastName('B Markussen'); $user->setGender('0'); $user->setPhone('495479563'); $user->setUserName('petter'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('x@b.c'); $user->setFirstName('Christian'); $user->setLastName('Due Lind'); $user->setGender('0'); $user->setPhone('40490269'); $user->setUserName('christian'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('y@b.c'); $user->setFirstName('Silje'); $user->setLastName('Sekkingstad Hauge'); $user->setGender('1'); $user->setPhone('91335316'); $user->setUserName('silje'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('z@b.c'); $user->setFirstName('Karoline'); $user->setLastName('Aasen Nilsen'); $user->setGender('1'); $user->setPhone('22000000'); $user->setUserName('karoline'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('aa@b.c'); $user->setFirstName('Hanne'); $user->setLastName('Høie Grøttum'); $user->setGender('1'); $user->setPhone('40000000'); $user->setUserName('hanne'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ab@b.c'); $user->setFirstName('Øivind'); $user->setLastName('Mathias Gitmark'); $user->setGender('0'); $user->setPhone('37000000'); $user->setUserName('oyvind'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ac@b.c'); $user->setFirstName('Vilde'); $user->setLastName('Aasvær Sømnes'); $user->setGender('1'); $user->setPhone('90792997'); $user->setUserName('vilde'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ad@b.c'); $user->setFirstName('Per Ivar'); $user->setLastName('Hoff'); $user->setGender('0'); $user->setPhone('90969768'); $user->setUserName('per'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ae@b.c'); $user->setFirstName('Sigrid'); $user->setLastName('Baardsdatter Kleveland'); $user->setGender('1'); $user->setPhone('97152206'); $user->setUserName('sigridb'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('af@b.c'); $user->setFirstName('Simen'); $user->setLastName('Svagård'); $user->setGender('0'); $user->setPhone('48058898'); $user->setUserName('simen'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ag@b.c'); $user->setFirstName('Martine'); $user->setLastName('Rønneberg'); $user->setGender('1'); $user->setPhone('41078184'); $user->setUserName('martine'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ah@b.c'); $user->setFirstName('Vida'); $user->setLastName('Mortensen Gråberg'); $user->setGender('1'); $user->setPhone('97133990'); $user->setUserName('vida'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ai@b.c'); $user->setFirstName('Filip Emil'); $user->setLastName('Schjerven'); $user->setGender('0'); $user->setPhone('93499748'); $user->setUserName('filip'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('aj@b.c'); $user->setFirstName('Harald'); $user->setLastName('Blehr '); $user->setGender('0'); $user->setPhone('99441106'); $user->setUserName('harald'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ak@b.c'); $user->setFirstName('Audun'); $user->setLastName('Mathias Øvstebø'); $user->setGender('0'); $user->setPhone('95421307'); $user->setUserName('audun'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('al@b.c'); $user->setFirstName('Kristoffer'); $user->setLastName('Berg'); $user->setGender('0'); $user->setPhone('41333909'); $user->setUserName('kristoffer'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('am@b.c'); $user->setFirstName('Ingvild'); $user->setLastName('Grøtte Bostrøm'); $user->setGender('1'); $user->setPhone('41487316'); $user->setUserName('ingvild'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('an@b.c'); $user->setFirstName('Polina'); $user->setLastName('Pires Ferreira'); $user->setGender('1'); $user->setPhone('74000000'); $user->setUserName('polina'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ao@b.c'); $user->setFirstName('Håvard'); $user->setLastName('Kjellmo Arnestad'); $user->setGender('0'); $user->setPhone('99442592'); $user->setUserName('haavard'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ap@b.c'); $user->setFirstName('Lisa'); $user->setLastName('Sletten'); $user->setGender('1'); $user->setPhone('42000000'); $user->setUserName('lisa'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('aq@b.c'); $user->setFirstName('Heidi Elisabeth'); $user->setLastName('Sando'); $user->setGender('1'); $user->setPhone('41000000'); $user->setUserName('heidi'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ar@b.c'); $user->setFirstName('Maren'); $user->setLastName('Dekov'); $user->setGender('1'); $user->setPhone('91000000'); $user->setUserName('marend'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('as@b.c'); $user->setFirstName('Mina'); $user->setLastName('Rahimzaie'); $user->setGender('1'); $user->setPhone('98671137'); $user->setUserName('mina'); $user->setPassword('123'); $user->addRole($this->getReference('role-2')); $user->setFieldOfStudy($this->getReference('fos-4')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('at@b.c'); $user->setFirstName('Maren Anna'); $user->setLastName('Brandsrud'); $user->setGender('1'); $user->setPhone('93606278'); $user->setUserName('marenab'); $user->setPassword('123'); $user->addRole($this->getReference('role-2')); $user->setFieldOfStudy($this->getReference('fos-4')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('au@b.c'); $user->setFirstName('Simen'); $user->setLastName('Rønnekleiv Eriksen'); $user->setGender('0'); $user->setPhone('91802553'); $user->setUserName('simenr'); $user->setPassword('123'); $user->addRole($this->getReference('role-2')); $user->setFieldOfStudy($this->getReference('fos-4')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('av@b.c'); $user->setFirstName('Yen-Nhi'); $user->setLastName('Doan'); $user->setGender('1'); $user->setPhone('41741744'); $user->setUserName('yennhi'); $user->setPassword('123'); $user->addRole($this->getReference('role-2')); $user->setFieldOfStudy($this->getReference('fos-4')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('aw@b.c'); $user->setFirstName('Vilde'); $user->setLastName('Strøm'); $user->setGender('1'); $user->setPhone('40042692'); $user->setUserName('vildes'); $user->setPassword('123'); $user->addRole($this->getReference('role-2')); $user->setFieldOfStudy($this->getReference('fos-5')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ax@b.c'); $user->setFirstName('Camilla'); $user->setLastName('Restrup Strand'); $user->setGender('1'); $user->setPhone('92428152'); $user->setUserName('camilla'); $user->setPassword('123'); $user->addRole($this->getReference('role-2')); $user->setFieldOfStudy($this->getReference('fos-5')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('ay@b.c'); $user->setFirstName('Jonathan'); $user->setLastName('Stang'); $user->setGender('0'); $user->setPhone('45883454'); $user->setUserName('jonathan'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-5')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('az@b.c'); $user->setFirstName('Ingrid'); $user->setLastName('Meland'); $user->setGender('1'); $user->setPhone('90760750'); $user->setUserName('ingridm'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-5')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('aaa@b.c'); $user->setFirstName('Fredrik'); $user->setLastName('Vegstein'); $user->setGender('0'); $user->setPhone('95496787'); $user->setUserName('fredrik'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-5')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('aab@b.c'); $user->setFirstName('Kristian'); $user->setLastName('Tuv'); $user->setGender('0'); $user->setPhone('95901921'); $user->setUserName('kritu'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-5')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('aac@b.c'); $user->setFirstName('Hans Petter'); $user->setLastName('Harveg'); $user->setGender('0'); $user->setPhone('92439505'); $user->setUserName('hans'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-5')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('aad@b.c'); $user->setFirstName('Daniel'); $user->setLastName('Joly'); $user->setGender('0'); $user->setPhone('45073168'); $user->setUserName('daniel'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-5')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('aae@b.c'); $user->setFirstName('Sigrid'); $user->setLastName('Da Costa'); $user->setGender('1'); $user->setPhone('95944622'); $user->setUserName('sigridd'); $user->setPassword('123'); $user->addRole($this->getReference('role-1')); $user->setFieldOfStudy($this->getReference('fos-5')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user10 = new User(); $user10->setIsActive('1'); $user10->setEmail('aaf@b.c'); $user10->setFirstName('Kamilla'); $user10->setLastName('Plaszko'); $user10->setGender('1'); $user10->setPhone('45484008'); $user10->setUserName('kampla'); $user10->setPassword('123'); $user10->addRole($this->getReference('role-1')); $user10->setFieldOfStudy($this->getReference('fos-5')); $user10->setPicturePath('images/defaultProfile.png'); $manager->persist($user10); $user11 = new User(); $user11->setIsActive('1'); $user11->setEmail('aag@b.c'); $user11->setFirstName('Vuk'); $user11->setLastName('Krivokapic'); $user11->setGender('0'); $user11->setPhone('47000000'); $user11->setUserName('vuk'); $user11->setPassword('123'); $user11->addRole($this->getReference('role-2')); $user11->setFieldOfStudy($this->getReference('fos-3')); $user11->setPicturePath('images/defaultProfile.png'); $manager->persist($user11); $user12 = new User(); $user12->setIsActive('1'); $user12->setEmail('aah@b.c'); $user12->setFirstName('Markus'); $user12->setLastName('Gundersen'); $user12->setGender('0'); $user12->setPhone('46000000'); $user12->setUserName('markus'); $user12->setPassword('123'); $user12->addRole($this->getReference('role-2')); $user12->setFieldOfStudy($this->getReference('fos-3')); $user12->setPicturePath('images/defaultProfile.png'); $manager->persist($user12); $user13 = new User(); $user13->setIsActive('1'); $user13->setEmail('aai@b.c'); $user13->setFirstName('Erik'); $user13->setLastName('Trondsen '); $user13->setGender('0'); $user13->setPhone('45000000'); $user13->setUserName('erik'); $user13->setPassword('123'); $user13->addRole($this->getReference('role-1')); $user13->setFieldOfStudy($this->getReference('fos-3')); $user13->setPicturePath('images/defaultProfile.png'); $manager->persist($user13); $user14 = new User(); $user14->setIsActive('1'); $user14->setEmail('*****@*****.**'); $user14->setFirstName('Assistent'); $user14->setLastName('Johansen'); $user14->setGender('0'); $user14->setPhone('47658937'); $user14->setUserName('assistent'); $user14->setPassword('1234'); $user14->addRole($this->getReference('role-3')); $user14->setFieldOfStudy($this->getReference('fos-1')); $user14->setPicturePath('images/defaultProfile.png'); $manager->persist($user14); $user15 = new User(); $user15->setIsActive('1'); $user15->setEmail('*****@*****.**'); $user15->setFirstName('Team'); $user15->setLastName('Johansen'); $user15->setGender('0'); $user15->setPhone('47658937'); $user15->setUserName('team'); $user15->setPassword('1234'); $user15->addRole($this->getReference('role-1')); $user15->setFieldOfStudy($this->getReference('fos-1')); $user15->setPicturePath('images/defaultProfile.png'); $manager->persist($user15); $user = new User(); $user->setIsActive('1'); $user->setEmail('*****@*****.**'); $user->setFirstName('Admin'); $user->setLastName('Johansen'); $user->setGender('0'); $user->setPhone('47658937'); $user->setUserName('admin'); $user->setPassword('1234'); $user->addRole($this->getReference('role-2')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $user = new User(); $user->setIsActive('1'); $user->setEmail('*****@*****.**'); $user->setFirstName('Superadmin'); $user->setLastName('Johansen'); $user->setGender('0'); $user->setPhone('47658937'); $user->setUserName('superadmin'); $user->setPassword('1234'); $user->addRole($this->getReference('role-4')); $user->setFieldOfStudy($this->getReference('fos-1')); $user->setPicturePath('images/defaultProfile.png'); $manager->persist($user); $manager->flush(); $this->setReference('user-1', $user1); $this->setReference('user-2', $user2); $this->setReference('user-3', $user3); $this->setReference('user-4', $user4); $this->setReference('user-8', $user8); $this->setReference('user-9', $user9); $this->setReference('user-10', $user10); $this->setReference('user-11', $user11); $this->setReference('user-12', $user12); $this->setReference('user-13', $user13); $this->setReference('user-14', $user14); $this->setReference('user-15', $user15); }
/** * @param ObjectManager $manager */ protected function loadUsers(ObjectManager $manager) { $user = new User(); $user->setEmail('*****@*****.**'); $user->setFirstName('Kalle'); $user->setLastName('Anka'); $user->setEnabled(true); $user->addRole('ROLE_COMPLETE_USER'); $user->setWantToLearn(true); $user->setAge(35); $user->setAbout('Sportintresserad man med 3 barn'); $user->setCategories([$this->getReference('category-1'), $this->getReference('category-2')]); $user->setFrom('SY'); $user->setGender('M'); $user->setProfilePicture('http://api.randomuser.me/portraits/thumb/men/1.jpg'); $encoder = $this->container->get('security.encoder_factory')->getEncoder($user); $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt())); $manager->persist($user); $this->addReference('user-learner', $user); $user = new User(); $user->setEmail('*****@*****.**'); $user->setFirstName('Kal p'); $user->setLastName('Dal'); $user->setEnabled(true); $user->setRoles(['ROLE_COMPLETE_USER', 'ROLE_ADMIN']); $user->setWantToLearn(false); $user->setAge(40); $user->setAbout('Sportintresserad lärare'); $user->setCategories([$this->getReference('category-0'), $this->getReference('category-1')]); $user->setFrom('SE'); $user->setGender('M'); $user->setProfilePicture('http://api.randomuser.me/portraits/thumb/men/2.jpg'); $encoder = $this->container->get('security.encoder_factory')->getEncoder($user); $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt())); $manager->persist($user); $this->addReference('user-fluentspeaker', $user); $user = new User(); $user->setEmail('*****@*****.**'); $user->setFirstName('Glenn'); $user->setLastName('GBG'); $user->setEnabled(true); $user->setRoles(['ROLE_COMPLETE_USER', 'ROLE_ADMIN']); $user->setWantToLearn(false); $user->setAge(20); $user->setAbout('Göteborgare'); $user->setCategories([$this->getReference('category-1'), $this->getReference('category-2')]); $user->setFrom('SE'); $user->setGender('M'); $user->setProfilePicture('http://api.randomuser.me/portraits/thumb/men/3.jpg'); $encoder = $this->container->get('security.encoder_factory')->getEncoder($user); $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt())); $manager->persist($user); $this->addReference('user-glenn', $user); $user = new User(); $user->setEmail('*****@*****.**'); $user->setEnabled(true); $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt())); $manager->persist($user); }
/** * Creates an unactivated user for the given application. * This method is intended to be called by an Ajax request. * TODO: FIll in description * * @param $id * @return JsonResponse */ public function createUnactivatedUserAction($id) { try { $em = $this->getDoctrine()->getManager(); $application = $em->getRepository('AppBundle:Application')->findApplicantById($id); $role = $em->getRepository('AppBundle:Role')->findOneByName(AdmissionAdminController::NEW_USER_ROLE); // Create the hash $createNewUserCode = bin2hex(openssl_random_pseudo_bytes(16)); $hashedNewUserCode = hash('sha512', $createNewUserCode, false); // Copy information from the given application to a new user $user = new User(); $user->setLastName($application->getLastName()); $user->setFirstName($application->getFirstName()); $user->setGender($application->getStatistic()->getGender()); $user->setPhone($application->getPhone()); $user->setFieldOfStudy($application->getStatistic()->getFieldOfStudy()); $user->setEmail($application->getEmail()); // Create Username from email, and make sure it's unique $new_username = explode("@", $application->getEmail())[0]; $user_rep = $em->getRepository('AppBundle:User'); $violator = $user_rep->findOneBy(array('user_name' => $new_username)); $postfix = 0; while ($violator) { $postfix++; $violator = $user_rep->findOneBy(array('user_name' => $new_username . $postfix)); } if ($postfix) { $new_username = $new_username . $postfix; } $user->setUserName($new_username); $user->setPassword($new_username); $user->setIsActive('0'); $user->setNewUserCode($hashedNewUserCode); // Give the new user the default role $user->addRole($role); // Update the application $application->setUserCreated(true); // Update application statistic $application->getStatistic()->setAccepted(true); // Persist $em->persist($application); $em->persist($user); $em->flush(); //Sends a email with the url for resetting the password //echo('127.0.0.1:8000/opprettbruker/'.$createNewUserCode.''); $this->sendNewUserEmail($createNewUserCode, $user->getEmail()); return new JsonResponse(['success' => true]); } catch (\Exception $e) { // If it is a integrity violation constraint (i.e a user with the email already exists) if ($e->getPrevious()) { //If the error occurred when sending email, $e->getPrevious() will be null if ($e->getPrevious()->getCode() == 23000) { $message = 'En bruker med denne E-posten eksisterer allerede.'; } } else { $message = 'En feil oppstod. Kontakt IT ansvarlig.'; } return new JsonResponse(['success' => false, 'cause' => $message]); } }
public function update(User $user, $firstname, $lastname, $email, $username, $password, $about, $picture, $location, $locationCityShort, $locationCityLong, $locationStateShort, $locationStateLong, $locationCountryShort, $locationCountryLong, $gender, $company, $isAvailableToHiring, $contactWebsite, $contactTwitter, $contactLinkedIn, $contactCertification, $contactGitHub, $contactStackOverflow) { if ($errors = $this->getErrors($firstname, $lastname, $email, $username, $password, $about, $locationCityShort, $locationCityLong, $locationStateShort, $locationStateLong, $locationCountryShort, $locationCountryLong, $gender, $company, $isAvailableToHiring, true, $password == '' ? false : true)) { throw new ServiceException($errors); } $user->setUsername($username); $user->setFirstname($firstname); $user->setLastname($lastname); $user->setEmail($email); $user->setAbout($about); $user->setLocation($location); $user->setLocationCityShort($locationCityShort); $user->setLocationCityLong($locationCityLong); $user->setLocationStateShort($locationStateShort); $user->setLocationStateLong($locationStateLong); $user->setLocationCountryShort($locationCountryShort); $user->setLocationCountryLong($locationCountryLong); $user->setGender($gender); $user->setCompany($company); $user->setIsAvailableToHiring($isAvailableToHiring); $user->setContactWebsite($contactWebsite); $user->setContactTwitter($contactTwitter); $user->setContactLinkedIn($contactLinkedIn); $user->setContactCertification($contactCertification); $user->setContactGitHub($contactGitHub); $user->setContactStackOverflow($contactStackOverflow); $user->setUpdatedAt(new \DateTime()); if ($picture) { $user->setPicturePath($this->moveImageFromTmpToFolder($picture)); } if ($password) { $user->setPassword(md5($password)); } return $this->repository->create($user); }