+ *
+ * @method User|null find($id, $lockMode = null, $lockVersion = null)
+ * @method User|null findOneBy(array $criteria, array $orderBy = null)
+ * @method User[] findAll()
+ * @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
+{
+ public function __construct(ManagerRegistry $registry)
+ {
+ parent::__construct($registry, User::class);
+ }
+
+ /**
+ * Used to upgrade (rehash) the user's password automatically over time.
+ */
+ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
+ {
+ if (!$user instanceof User) {
+ throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
+ }
+
+ $user->setPassword($newHashedPassword);
+ $this->getEntityManager()->persist($user);
+ $this->getEntityManager()->flush();
+ }
+
+// /**
+// * @return User[] Returns an array of User objects
+// */
+// public function findByExampleField($value): array
+// {
+// return $this->createQueryBuilder('u')
+// ->andWhere('u.exampleField = :val')
+// ->setParameter('val', $value)
+// ->orderBy('u.id', 'ASC')
+// ->setMaxResults(10)
+// ->getQuery()
+// ->getResult()
+// ;
+// }
+
+// public function findOneBySomeField($value): ?User
+// {
+// return $this->createQueryBuilder('u')
+// ->andWhere('u.exampleField = :val')
+// ->setParameter('val', $value)
+// ->getQuery()
+// ->getOneOrNullResult()
+// ;
+// }
+}
diff --git a/src/Security/LoginFormAuthenticator.php b/src/Security/LoginFormAuthenticator.php
new file mode 100644
index 0000000..84bebf1
--- /dev/null
+++ b/src/Security/LoginFormAuthenticator.php
@@ -0,0 +1,59 @@
+request->get('username', '');
+
+ $request->getSession()->set(Security::LAST_USERNAME, $username);
+
+ return new Passport(
+ new UserBadge($username),
+ new PasswordCredentials($request->request->get('password', '')),
+ [
+ new CsrfTokenBadge('authenticate', $request->request->get('_csrf_token')),
+ new RememberMeBadge(),
+ ]
+ );
+ }
+
+ public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
+ {
+ if ($targetPath = $this->getTargetPath($request->getSession(), $firewallName)) {
+ return new RedirectResponse($targetPath);
+ }
+
+ return new RedirectResponse($this->urlGenerator->generate('app_home'));
+ }
+
+ protected function getLoginUrl(Request $request): string
+ {
+ return $this->urlGenerator->generate(self::LOGIN_ROUTE);
+ }
+
+}
diff --git a/templates/auth/login.html.twig b/templates/auth/login.html.twig
new file mode 100644
index 0000000..e6b945f
--- /dev/null
+++ b/templates/auth/login.html.twig
@@ -0,0 +1,43 @@
+{% extends 'base.html.twig' %}
+
+{% block title %}Connexion{% endblock %}
+
+{% block stylesheets %}
+ {{ parent() }}
+
+{% endblock %}
+
+{% block body %}
+
+
+
🔐 Connexion
+
+ {% if error %}
+
Mauvais nom d'utilisateur ou mot de passe.
+ {% endif %}
+
+ {% if app.user %}
+
+ Connecté en tant que {{ app.user.userIdentifier }},
+
Se déconnecter
+
+ {% endif %}
+
+
+
+
+
+{% endblock %}
diff --git a/templates/auth/register.html.twig b/templates/auth/register.html.twig
new file mode 100644
index 0000000..3e7cb4d
--- /dev/null
+++ b/templates/auth/register.html.twig
@@ -0,0 +1,30 @@
+{% extends 'base.html.twig' %}
+
+{% block title %}Inscription{% endblock %}
+
+{% block stylesheets %}
+ {{ parent() }}
+
+{% endblock %}
+
+{% block body %}
+
+
📝 Inscription
+
+ {{ form_start(registrationForm, {'attr': {'class': 'register-form'}}) }}
+ {{ form_errors(registrationForm) }}
+
+ {{ form_row(registrationForm.username) }}
+ {{ form_row(registrationForm.plainPassword, {
+ label: 'Mot de passe'
+ }) }}
+
+
+
+
+ {{ form_end(registrationForm) }}
+
+{% endblock %}
diff --git a/templates/home/index.html.twig b/templates/home/index.html.twig
index d48c919..056f8d5 100644
--- a/templates/home/index.html.twig
+++ b/templates/home/index.html.twig
@@ -7,9 +7,49 @@
{% endblock %}
{% block body %}
+ {% if app.user %}
+
+ Connecté en tant que {{ app.user.username }}
+
+
+ {% endif %}
🧬 Ma collection de créatures 🐾
+ 🌱 Vos créatures de base
+
+
+ {% for emoji in emojisDeBase %}
+
+
+
Level {{ emoji.nbCombatGagne }}
+
{{ emoji.code }}
+
{{ emoji.nom }}
+
ℹ️
+
+
+
+ {% endfor %}
+
+
+ 🔻
+
+ 📦 Votre collection personnelle
+
@@ -32,18 +72,20 @@
- Sélectionnez 2 créatures...
-
-
- {% for emoji in emojis %}
-
+
+ {% for emoji in emojisCrees %}
+
Level {{ emoji.nbCombatGagne }}
{{ emoji.code }}
{{ emoji.nom }}
-
ℹ️
+
ℹ️
+
+
+
Sélectionnez 2 créatures de votre choix pour commencer ...
+
-
-
+
+
{% endblock %}
{% block javascripts %}
-
+
{% endblock %}
\ No newline at end of file