diff --git a/.idea/giftopic.iml b/.idea/giftopic.iml
index cedceab..1102adb 100644
--- a/.idea/giftopic.iml
+++ b/.idea/giftopic.iml
@@ -5,6 +5,7 @@
+
diff --git a/.idea/webResources.xml b/.idea/webResources.xml
new file mode 100644
index 0000000..3432ba4
--- /dev/null
+++ b/.idea/webResources.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/packages/security.yaml b/config/packages/security.yaml
index 087e1fd..316d782 100644
--- a/config/packages/security.yaml
+++ b/config/packages/security.yaml
@@ -20,9 +20,11 @@ security:
secure: true
guard:
authenticators:
- - App\Security\LoginFormAuthentificatorAuthenticator
+ - App\Security\LoginFormAuthenticator
logout:
path: app_security_logout
- target: app_external_index
+ target: app_site_index
access_control:
- { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
+ role_hierarchy:
+ ROLE_ADMIN: ROLE_USER
diff --git a/config/packages/test/framework.yaml b/config/packages/test/framework.yaml
deleted file mode 100644
index d051c84..0000000
--- a/config/packages/test/framework.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-framework:
- test: true
- session:
- storage_id: session.storage.mock_file
diff --git a/config/packages/test/monolog.yaml b/config/packages/test/monolog.yaml
deleted file mode 100644
index fc40641..0000000
--- a/config/packages/test/monolog.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-monolog:
- handlers:
- main:
- type: fingers_crossed
- action_level: error
- handler: nested
- excluded_http_codes: [404, 405]
- channels: ["!event"]
- nested:
- type: stream
- path: "%kernel.logs_dir%/%kernel.environment%.log"
- level: debug
diff --git a/config/packages/test/twig.yaml b/config/packages/test/twig.yaml
deleted file mode 100644
index 8c6e0b4..0000000
--- a/config/packages/test/twig.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-twig:
- strict_variables: true
diff --git a/config/packages/test/validator.yaml b/config/packages/test/validator.yaml
deleted file mode 100644
index 1e5ab78..0000000
--- a/config/packages/test/validator.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-framework:
- validation:
- not_compromised_password: false
diff --git a/config/packages/test/web_profiler.yaml b/config/packages/test/web_profiler.yaml
deleted file mode 100644
index 03752de..0000000
--- a/config/packages/test/web_profiler.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-web_profiler:
- toolbar: false
- intercept_redirects: false
-
-framework:
- profiler: { collect: false }
diff --git a/config/packages/translation.yaml b/config/packages/translation.yaml
index 1d7cded..05a2b3d 100644
--- a/config/packages/translation.yaml
+++ b/config/packages/translation.yaml
@@ -1,6 +1,6 @@
framework:
- default_locale: fr
+ default_locale: en
translator:
default_path: '%kernel.project_dir%/translations'
fallbacks:
- - fr
+ - en
diff --git a/config/routes.yaml b/config/routes.yaml
index 7e8fe18..e6c1223 100644
--- a/config/routes.yaml
+++ b/config/routes.yaml
@@ -1,7 +1,7 @@
# Redirige l'URL racine vers celle de la langue par défaut
index:
path: /
- controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController
+ controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
defaults:
route: 'app_external_index'
_locale: '%kernel.default_locale%'
diff --git a/src/Controller/ExternalController.php b/src/Controller/SiteController.php
similarity index 51%
rename from src/Controller/ExternalController.php
rename to src/Controller/SiteController.php
index 00c984c..bc456e0 100644
--- a/src/Controller/ExternalController.php
+++ b/src/Controller/SiteController.php
@@ -2,14 +2,17 @@
namespace App\Controller;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
-class ExternalController extends AbstractController {
+class SiteController extends AbstractController {
/**
* @Route("/")
+ *
+ * @IsGranted("ROLE_USER")
*/
public function index () {
- return $this->render('external/index.html.twig');
+ return $this->render('site/index.html.twig');
}
}
\ No newline at end of file
diff --git a/src/Entity/User.php b/src/Entity/User.php
index c47da02..37fd3c0 100644
--- a/src/Entity/User.php
+++ b/src/Entity/User.php
@@ -10,8 +10,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
-class User implements UserInterface
-{
+class User implements UserInterface {
/**
* @var int The internal ID of user
*
@@ -48,14 +47,12 @@ class User implements UserInterface
* @ORM\Column(type="string", length=255)
*/
private string $name;
-
/**
* @var string|null The user first name
*
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $fist_name;
-
/**
* @var int The user gender
* 0 = no gender
@@ -66,7 +63,6 @@ class User implements UserInterface
* @ORM\Column(type="smallint")
*/
private int $gender;
-
/**
* @var string|null The user avatar relative path
*
@@ -96,35 +92,30 @@ class User implements UserInterface
* )
*/
private ArrayCollection $friends;
-
/**
* @var ArrayCollection The user {@see ConfigNotification configured notifications}
*
* @ORM\OneToMany(targetEntity="App\Entity\ConfigNotification", mappedBy="user", orphanRemoval=true)
*/
private ArrayCollection $configNotifications;
-
/**
* @var ArrayCollection Thue user {@see UserNotification notifications}
*
* @ORM\OneToMany(targetEntity="App\Entity\UserNotification", mappedBy="user", orphanRemoval=true)
*/
private ArrayCollection $notifications;
-
/**
* @var ArrayCollection The user owned {@see Wish wishes}
*
* @ORM\OneToMany(targetEntity="App\Entity\Wish", mappedBy="owner")
*/
private ArrayCollection $ownedWishes;
-
/**
* @var ArrayCollection The user {@see Participant participations}
*
* @ORM\OneToMany(targetEntity="App\Entity\Participant", mappedBy="user", orphanRemoval=true)
*/
private ArrayCollection $participations;
-
/**
* @var ArrayCollection The user {@see Comment comments}
*
@@ -132,13 +123,6 @@ class User implements UserInterface
*/
private ArrayCollection $comments;
- /**
- * @var bool Is the user inactive ?
- *
- * @ORM\Column(type="boolean")
- */
- private $inactive;
-
public function __construct () {
$this->friends = new ArrayCollection();
$this->configNotifications = new ArrayCollection();
@@ -148,18 +132,14 @@ class User implements UserInterface
$this->comments = new ArrayCollection();
}
- public function getId(): ?int
- {
+ public function getId (): ?int {
return $this->id;
}
- public function getEmail(): ?string
- {
+ public function getEmail (): ?string {
return $this->email;
}
-
- public function setEmail(string $email): self
- {
+ public function setEmail (string $email): self {
$this->email = $email;
return $this;
@@ -170,25 +150,22 @@ class User implements UserInterface
*
* @see UserInterface
*/
- public function getUsername(): string
- {
- return (string) $this->email;
+ public function getUsername (): string {
+ return (string)$this->email;
}
/**
* @see UserInterface
*/
- public function getRoles(): array
- {
+ public function getRoles (): array {
$roles = $this->roles;
- // guarantee every user at least has ROLE_USER
+
+ // Every user must have at least the ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
-
- public function setRoles(array $roles): self
- {
+ public function setRoles (array $roles): self {
$this->roles = $roles;
return $this;
@@ -197,13 +174,10 @@ class User implements UserInterface
/**
* @see UserInterface
*/
- public function getPassword(): string
- {
- return (string) $this->password;
+ public function getPassword (): string {
+ return (string)$this->password;
}
-
- public function setPassword(string $password): self
- {
+ public function setPassword (string $password): self {
$this->password = $password;
return $this;
@@ -212,16 +186,13 @@ class User implements UserInterface
/**
* @see UserInterface
*/
- public function getSalt()
- {
+ public function getSalt () {
// not needed when using the "bcrypt" algorithm in security.yaml
}
-
/**
* @see UserInterface
*/
- public function eraseCredentials()
- {
+ public function eraseCredentials () {
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
@@ -229,7 +200,6 @@ class User implements UserInterface
public function getName (): ?string {
return $this->name;
}
-
public function setName (string $name): self {
$this->name = $name;
@@ -239,7 +209,6 @@ class User implements UserInterface
public function getFistname (): ?string {
return $this->fist_name;
}
-
public function setFistname (?string $fist_name): self {
$this->fist_name = $fist_name;
@@ -249,7 +218,6 @@ class User implements UserInterface
public function getGender (): ?int {
return $this->gender;
}
-
public function setGender (int $gender): self {
$this->gender = $gender;
@@ -259,7 +227,6 @@ class User implements UserInterface
public function getAvatar (): ?string {
return $this->avatar;
}
-
public function setAvatar (?string $avatar): self {
$this->avatar = $avatar;
@@ -269,7 +236,6 @@ class User implements UserInterface
public function getLanguage (): ?Language {
return $this->language;
}
-
public function setLanguage (?Language $language): self {
$this->language = $language;
@@ -282,7 +248,6 @@ class User implements UserInterface
public function getFriends (): Collection {
return $this->friends;
}
-
public function addFriend (self $friend): self {
if (!$this->friends->contains($friend)) {
$this->friends[] = $friend;
@@ -290,7 +255,6 @@ class User implements UserInterface
return $this;
}
-
public function removeFriend (self $friend): self {
if ($this->friends->contains($friend)) {
$this->friends->removeElement($friend);
@@ -305,7 +269,6 @@ class User implements UserInterface
public function getConfigNotifications (): Collection {
return $this->configNotifications;
}
-
public function addConfigNotification (ConfigNotification $configNotification): self {
if (!$this->configNotifications->contains($configNotification)) {
$this->configNotifications[] = $configNotification;
@@ -314,7 +277,6 @@ class User implements UserInterface
return $this;
}
-
public function removeConfigNotification (ConfigNotification $configNotification): self {
if ($this->configNotifications->contains($configNotification)) {
$this->configNotifications->removeElement($configNotification);
@@ -333,7 +295,6 @@ class User implements UserInterface
public function getNotifications (): Collection {
return $this->notifications;
}
-
public function addNotification (UserNotification $notification): self {
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
@@ -342,7 +303,6 @@ class User implements UserInterface
return $this;
}
-
public function removeNotification (UserNotification $notification): self {
if ($this->notifications->contains($notification)) {
$this->notifications->removeElement($notification);
@@ -358,13 +318,10 @@ class User implements UserInterface
/**
* @return Collection|Wish[]
*/
- public function getOwnedWishes(): Collection
- {
+ public function getOwnedWishes (): Collection {
return $this->ownedWishes;
}
-
- public function addOwnedWish(Wish $ownedWish): self
- {
+ public function addOwnedWish (Wish $ownedWish): self {
if (!$this->ownedWishes->contains($ownedWish)) {
$this->ownedWishes[] = $ownedWish;
$ownedWish->setOwner($this);
@@ -372,9 +329,7 @@ class User implements UserInterface
return $this;
}
-
- public function removeOwnedWish(Wish $ownedWish): self
- {
+ public function removeOwnedWish (Wish $ownedWish): self {
if ($this->ownedWishes->contains($ownedWish)) {
$this->ownedWishes->removeElement($ownedWish);
// set the owning side to null (unless already changed)
@@ -389,13 +344,10 @@ class User implements UserInterface
/**
* @return Collection|Participant[]
*/
- public function getParticipations(): Collection
- {
+ public function getParticipations (): Collection {
return $this->participations;
}
-
- public function addParticipation(Participant $participation): self
- {
+ public function addParticipation (Participant $participation): self {
if (!$this->participations->contains($participation)) {
$this->participations[] = $participation;
$participation->setUser($this);
@@ -403,9 +355,7 @@ class User implements UserInterface
return $this;
}
-
- public function removeParticipation(Participant $participation): self
- {
+ public function removeParticipation (Participant $participation): self {
if ($this->participations->contains($participation)) {
$this->participations->removeElement($participation);
// set the owning side to null (unless already changed)
@@ -420,13 +370,10 @@ class User implements UserInterface
/**
* @return Collection|Comment[]
*/
- public function getComments(): Collection
- {
+ public function getComments (): Collection {
return $this->comments;
}
-
- public function addComment(Comment $comment): self
- {
+ public function addComment (Comment $comment): self {
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setUser($this);
@@ -434,9 +381,7 @@ class User implements UserInterface
return $this;
}
-
- public function removeComment(Comment $comment): self
- {
+ public function removeComment (Comment $comment): self {
if ($this->comments->contains($comment)) {
$this->comments->removeElement($comment);
// set the owning side to null (unless already changed)
@@ -447,16 +392,4 @@ class User implements UserInterface
return $this;
}
-
- public function getInactive(): ?bool
- {
- return $this->inactive;
- }
-
- public function setInactive(bool $inactive): self
- {
- $this->inactive = $inactive;
-
- return $this;
- }
}
diff --git a/src/Security/LoginFormAuthentificatorAuthenticator.php b/src/Security/LoginFormAuthenticator.php
similarity index 88%
rename from src/Security/LoginFormAuthentificatorAuthenticator.php
rename to src/Security/LoginFormAuthenticator.php
index 6302519..638588a 100644
--- a/src/Security/LoginFormAuthentificatorAuthenticator.php
+++ b/src/Security/LoginFormAuthenticator.php
@@ -20,13 +20,13 @@ use Symfony\Component\Security\Guard\Authenticator\AbstractFormLoginAuthenticato
use Symfony\Component\Security\Guard\PasswordAuthenticatedInterface;
use Symfony\Component\Security\Http\Util\TargetPathTrait;
-class LoginFormAuthentificatorAuthenticator extends AbstractFormLoginAuthenticator implements PasswordAuthenticatedInterface {
+class LoginFormAuthenticator extends AbstractFormLoginAuthenticator implements PasswordAuthenticatedInterface {
use TargetPathTrait;
- private $entityManager;
- private $urlGenerator;
- private $csrfTokenManager;
- private $passwordEncoder;
+ private EntityManagerInterface $entityManager;
+ private UrlGeneratorInterface $urlGenerator;
+ private CsrfTokenManagerInterface $csrfTokenManager;
+ private UserPasswordEncoderInterface $passwordEncoder;
public function __construct (
EntityManagerInterface $entityManager,
@@ -80,6 +80,10 @@ class LoginFormAuthentificatorAuthenticator extends AbstractFormLoginAuthenticat
/**
* Used to upgrade (rehash) the user's password automatically over time.
+ *
+ * @param string[] $credentials Old informations
+ *
+ * @return string|null
*/
public function getPassword ($credentials): ?string {
return $credentials['password'];
@@ -90,7 +94,7 @@ class LoginFormAuthentificatorAuthenticator extends AbstractFormLoginAuthenticat
return new RedirectResponse($targetPath);
}
- return new RedirectResponse($this->urlGenerator->generate('app_external_index'));
+ return new RedirectResponse($this->urlGenerator->generate('app_site_index'));
}
protected function getLoginUrl () {
diff --git a/templates/external/index.html.twig b/templates/site/index.html.twig
similarity index 100%
rename from templates/external/index.html.twig
rename to templates/site/index.html.twig
diff --git a/translations/security+intl-icu.en.xlf b/translations/security+intl-icu.en.xlf
new file mode 100644
index 0000000..805e560
--- /dev/null
+++ b/translations/security+intl-icu.en.xlf
@@ -0,0 +1,11 @@
+
+
+
+
+
+ Invalid credentials.
+ Invalid email or password.
+
+
+
+
\ No newline at end of file
diff --git a/translations/security+intl-icu.fr.xlf b/translations/security+intl-icu.fr.xlf
new file mode 100644
index 0000000..e814634
--- /dev/null
+++ b/translations/security+intl-icu.fr.xlf
@@ -0,0 +1,11 @@
+
+
+
+
+
+ Invalid credentials.
+ Email ou mot de passe incorrect
+
+
+
+
\ No newline at end of file