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