Example #1
0
 public function load(ObjectManager $em)
 {
     $user1 = new User();
     $user1->setAlertSetting(AlertSetting::ALL)->setEmail("overwatch.admin@example.com")->setEnabled(true)->setPlainPassword("p4ssw0rd")->setSuperAdmin(true);
     $em->persist($user1);
     $user2 = new User();
     $user2->setAlertSetting(AlertSetting::NONE)->setEmail("overwatch.user@example.com")->setEnabled(true)->setPlainPassword("p4ssw0rd")->setRoles(["ROLE_USER"]);
     $em->persist($user2);
     $user3 = new User();
     $user3->setAlertSetting(AlertSetting::NONE)->setEmail("overwatch.group.admin@example.com")->setEnabled(true)->setPlainPassword("p4ssw0rd")->setRoles(["ROLE_ADMIN"]);
     $em->persist($user3);
     $this->getReference('group-1')->addUser($user1);
     $this->getReference('group-1')->addUser($user2);
     $this->getReference('group-2')->addUser($user3);
     $this->addReference('user-1', $user1);
     $this->addReference('user-2', $user2);
     $this->addReference('user-3', $user3);
     $em->flush();
 }
 private function createUserMock($locked = false)
 {
     $user = new User();
     $user->setEmail("overwatch.test@example.com")->setLocked($locked)->resetApiKey();
     return $user;
 }
Example #3
0
 /**
  * Deletes the given user
  * 
  * @Route("/users/{id}")
  * @Method({"DELETE"})
  * @Security("has_role('ROLE_SUPER_ADMIN')")
  * @ApiDoc(
  *     requirements={
  *         {"name"="id", "description"="The ID of the user to delete", "dataType"="integer", "requirement"="\d+"}
  *     },
  *     tags={
  *         "Super Admin" = "#ff1919"
  *     }
  * )
  */
 public function deleteUser(User $user)
 {
     if ($user->getId() === $this->getUser()->getId()) {
         throw new AccessDeniedHttpException("You may not delete yourself.");
     }
     $this->_em->remove($user);
     $this->_em->flush();
     return new JsonResponse(NULL, JsonResponse::HTTP_NO_CONTENT);
 }
Example #4
0
 /**
  * Remove user
  *
  * @param \Overwatch\UserBundle\Entity\User $user
  */
 public function removeUser(\Overwatch\UserBundle\Entity\User $user)
 {
     $user->removeGroup($this);
     $this->users->removeElement($user);
 }