- Login fonctionnel
This commit is contained in:
@ -7,9 +7,11 @@ framework:
|
|||||||
# Enables session support. Note that the session will ONLY be started if you read or write from it.
|
# Enables session support. Note that the session will ONLY be started if you read or write from it.
|
||||||
# Remove or comment this section to explicitly disable session support.
|
# Remove or comment this section to explicitly disable session support.
|
||||||
session:
|
session:
|
||||||
handler_id: null
|
enabled: true
|
||||||
cookie_secure: auto
|
handler_id: null # Utilise le gestionnaire de sessions par défaut
|
||||||
cookie_samesite: lax
|
cookie_lifetime: 3600 # La durée de vie des cookies de session
|
||||||
|
cookie_secure: auto # Assure-toi que les cookies sont sécurisés (seulement en HTTPS)
|
||||||
|
cookie_samesite: lax # La politique SameSite des cookies
|
||||||
|
|
||||||
#esi: true
|
#esi: true
|
||||||
#fragments: true
|
#fragments: true
|
||||||
|
@ -10,23 +10,18 @@ security:
|
|||||||
class: App\Entity\User
|
class: App\Entity\User
|
||||||
property: email
|
property: email
|
||||||
firewalls:
|
firewalls:
|
||||||
dev:
|
|
||||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
|
||||||
security: false
|
|
||||||
main:
|
main:
|
||||||
lazy: true
|
lazy: true
|
||||||
provider: app_user_provider
|
provider: app_user_provider
|
||||||
|
form_login:
|
||||||
# activate different ways to authenticate
|
login_path: app_login
|
||||||
# https://symfony.com/doc/current/security.html#the-firewall
|
check_path: app_login
|
||||||
|
username_parameter: _username
|
||||||
# https://symfony.com/doc/current/security/impersonating_user.html
|
password_parameter: _password
|
||||||
# switch_user: true
|
default_target_path: home # Assure-toi que cette route existe
|
||||||
|
|
||||||
# Ajout de la gestion de la déconnexion
|
|
||||||
logout:
|
logout:
|
||||||
path: /logout # Route pour déconnecter l'utilisateur
|
path: /logout
|
||||||
target: /login # Redirection vers la page de login après déconnexion
|
target: /login
|
||||||
|
|
||||||
# Easy way to control access for large sections of your site
|
# Easy way to control access for large sections of your site
|
||||||
# Note: Only the *first* access control that matches will be used
|
# Note: Only the *first* access control that matches will be used
|
||||||
|
@ -31,6 +31,10 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
private ?string $lastName = null;
|
private ?string $lastName = null;
|
||||||
|
|
||||||
|
#[ORM\Column(type: "json")]
|
||||||
|
private array $roles = [];
|
||||||
|
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@ -103,16 +107,26 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||||||
|
|
||||||
public function getRoles(): array
|
public function getRoles(): array
|
||||||
{
|
{
|
||||||
// TODO: Implement getRoles() method.
|
|
||||||
|
$roles = $this->roles;
|
||||||
|
|
||||||
|
if (empty($roles)) {
|
||||||
|
$roles[] = 'ROLE_USER';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $roles;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eraseCredentials(): void
|
public function eraseCredentials(): void
|
||||||
{
|
{
|
||||||
// TODO: Implement eraseCredentials() method.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserIdentifier(): string
|
public function getUserIdentifier(): string
|
||||||
{
|
{
|
||||||
// TODO: Implement getUserIdentifier() method.
|
|
||||||
|
return $this->email; // Ou $this->pseudo si tu préfères utiliser le pseudo
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,11 +67,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{{ form_end(form) }}
|
{{ form_end(form) }}
|
||||||
{% if error %}
|
|
||||||
<div class="text-red-500 text-sm mt-2">
|
|
||||||
{{ error.messageKey|trans(error.messageData, 'security') }}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Reference in New Issue
Block a user