diff --git a/Symfony/src/AppBundle/Controller/DashboardController.php b/Symfony/src/AppBundle/Controller/DashboardController.php
index cbc605a..1ec243d 100644
--- a/Symfony/src/AppBundle/Controller/DashboardController.php
+++ b/Symfony/src/AppBundle/Controller/DashboardController.php
@@ -19,8 +19,11 @@ public function showAction($messages = [])
$tier = $this->getDoctrine()
->getRepository('AppBundle:Tier')
->find($user->getTier());
+ $tiers = $this->getDoctrine()
+ ->getRepository('AppBundle:Tier')
+ ->findAll();
return $this->render('AppBundle:Dashboard:index.html.twig',
- array('user' => $user, 'firmwares' => $firmwares, 'tier' => $tier, 'messages' => $messages));
+ array('user' => $user, 'firmwares' => $firmwares, 'tier' => $tier, 'tiers' => $tiers, 'messages' => $messages));
}
}
diff --git a/Symfony/src/AppBundle/Controller/RegisterController.php b/Symfony/src/AppBundle/Controller/RegisterController.php
index 8824593..077a49d 100644
--- a/Symfony/src/AppBundle/Controller/RegisterController.php
+++ b/Symfony/src/AppBundle/Controller/RegisterController.php
@@ -22,13 +22,17 @@ public function registerAction(Request $request)
if ($form->isSubmitted() && $form->isValid() && count($errors) == 0) {
$password = $this->get('security.password_encoder')->encodePassword($user, $user->getPassword());
$user->setPassword($password)->setSuccessfulFlashCount(0)->setTotalFlashCount(0)->setTier(0);
- $entityManager = $this->getDoctrine()->getManager();
- $entityManager->persist($user);
- $entityManager->flush();
- $token = new UsernamePasswordToken($user, null, 'login', $user->getRoles());
- $this->get('security.token_storage')->setToken($token);
- $messages = ["You have been registered!"];
- return $this->forward('AppBundle:Dashboard:show', array('messages' => $messages));
+ try {
+ $entityManager = $this->getDoctrine()->getManager();
+ $entityManager->persist($user);
+ $entityManager->flush();
+ $token = new UsernamePasswordToken($user, null, 'login', $user->getRoles());
+ $this->get('security.token_storage')->setToken($token);
+ $messages = ["You have been registered!"];
+ return $this->forward('AppBundle:Dashboard:show', array('messages' => $messages));
+ } catch(\Exception $e){
+ $errors = $e;
+ }
}
return $this->render('AppBundle:Register:index.html.twig', array('form' => $form->createView(), 'errors' => $errors));
diff --git a/Symfony/src/AppBundle/Controller/UpdateTierController.php b/Symfony/src/AppBundle/Controller/UpdateTierController.php
new file mode 100644
index 0000000..f7ca9e6
--- /dev/null
+++ b/Symfony/src/AppBundle/Controller/UpdateTierController.php
@@ -0,0 +1,25 @@
+request->all();
+ $entityManager = $this->getDoctrine()->getManager();
+ $user = $entityManager->getRepository('AppBundle:User')->find($owner);
+ if ($data["tier"] !== null && $data["tier"] > 0) {
+ $user->setTier($data["tier"]);
+ }
+ $entityManager->flush();
+ return new Response();
+ }
+}
diff --git a/Symfony/src/AppBundle/Entity/User.php b/Symfony/src/AppBundle/Entity/User.php
index 0d5bdbb..ddaaba1 100644
--- a/Symfony/src/AppBundle/Entity/User.php
+++ b/Symfony/src/AppBundle/Entity/User.php
@@ -6,12 +6,14 @@
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* User
*
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
- *
+ * @UniqueEntity(fields="email", message="Email is already in use")
+ * @UniqueEntity(fields="username", message="Username is already in use")
* @SuppressWarnings(PHPMD.ShortVariable)
*/
class User implements UserInterface, \Serializable
diff --git a/Symfony/src/AppBundle/Resources/views/Dashboard/index.html.twig b/Symfony/src/AppBundle/Resources/views/Dashboard/index.html.twig
index 06cb543..7f59e75 100644
--- a/Symfony/src/AppBundle/Resources/views/Dashboard/index.html.twig
+++ b/Symfony/src/AppBundle/Resources/views/Dashboard/index.html.twig
@@ -15,7 +15,17 @@
{% if tier != null %}
Your current tier is {{ tier.tierName }}.
{% endif %}
-
+
+