redirection good

This commit is contained in:
Olivier PARPAILLON
2024-11-19 14:01:57 +01:00
parent 8ddbf9c5d6
commit 5744d77e70
5 changed files with 32 additions and 11 deletions

View File

@@ -40,3 +40,21 @@ footer {
.star.text-yellow-500 { .star.text-yellow-500 {
color: gold; color: gold;
} }
.bgRegisterText {
color: #333333;
}
.bgRegister {
background-color: #A3D9B1;
}
.btnRegister {
background-color: #FF6F61;
border-color: #C8504C;
}
.btnRegister:hover {
background-color: rgb(218, 76, 93);
border-color: #FF6F61;
}

View File

@@ -22,12 +22,10 @@ security:
login_path: app_login login_path: app_login
check_path: app_login check_path: app_login
enable_csrf: true enable_csrf: true
default_target_path: home
always_use_default_target_path: true
logout: logout:
path: app_logout path: app_logout
target: app_login
# where to redirect after logout # where to redirect after logout
# target: app_any_route
# activate different ways to authenticate # activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall # https://symfony.com/doc/current/security.html#the-firewall
@@ -38,8 +36,9 @@ security:
# 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
access_control: access_control:
# - { path: ^/admin, roles: ROLE_ADMIN } - { path: ^/login, roles: PUBLIC_ACCESS }
# - { path: ^/profile, roles: ROLE_USER } - { path: ^/register, roles: PUBLIC_ACCESS }
- { path: ^/, roles: ROLE_USER }
when@test: when@test:
security: security:

View File

@@ -16,6 +16,10 @@ class LoginController extends AbstractController
#[Route(path: '/login', name: 'app_login')] #[Route(path: '/login', name: 'app_login')]
public function login(AuthenticationUtils $authenticationUtils, Security $security, Request $request): Response public function login(AuthenticationUtils $authenticationUtils, Security $security, Request $request): Response
{ {
if ($security->isGranted('ROLE_USER')) {
return $this->redirectToRoute('home'); // Redirection pour utilisateurs connectés
}
// get the login error if there is one // get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError(); $error = $authenticationUtils->getLastAuthenticationError();

View File

@@ -22,9 +22,9 @@
value="{{ csrf_token('authenticate') }}" value="{{ csrf_token('authenticate') }}"
> >
<div class="flex flex-row justify-between"> <div class="flex flex-row justify-between">
<button class="bg-blue-500 hover:bg-blue-400 text-white font-bold py-2 px-4 border-b-4 border-blue-700 hover:border-blue-500 rounded" type="submit">Se connecter</button> <button class=" text-white font-bold py-2 px-4 border-b-4 btnRegister rounded" type="submit">Se connecter</button>
<a href="{{ path('app_register') }}"> <a href="{{ path('app_register') }}">
<button class="bg-blue-500 hover:bg-blue-400 text-white font-bold py-2 px-4 border-b-4 border-blue-700 hover:border-blue-500 rounded mx-auto" type="button">S'inscrire</button> <button class=" text-white font-bold py-2 px-4 border-b-4 btnRegister rounded mx-auto" type="button">S'inscrire</button>
</a> </a>
</div> </div>
</form> </form>

View File

@@ -11,9 +11,9 @@
{% block content %} {% block content %}
<div class="flex flex-row justify-center items-stretch py-24"> <div class="flex flex-row justify-center items-stretch py-24">
<div class="bg-gray-500 shadow-lg p-8 max-w-sm text-center flex-1"> <div class="bgRegister shadow-lg p-8 max-w-sm text-center flex-1">
<h2 class="text-white text-2xl font-semibold py-6">Sortir !</h2> <h2 class="bgRegisterText text-2xl font-semibold py-6">Sortir !</h2>
<p class="text-lg text-gray-300 mt-3 leading-relaxed">Bienvenue sur notre application web référencant tout type d'évènements à travers le monde. N'hésitez pas à vous inscrire sur notre plateforme et y invitez vos amis afins de participer à des évènements simplement et qui vous conviennent !</p> <p class="text-lg bgRegisterText mt-3 leading-relaxed">Bienvenue sur notre application web référencant tout type d'évènements à travers le monde. N'hésitez pas à vous inscrire sur notre plateforme et y invitez vos amis afins de participer à des évènements simplement et qui vous conviennent !</p>
</div> </div>
<div class="bg-white shadow-lg p-8 max-w-sm text-center flex-1"> <div class="bg-white shadow-lg p-8 max-w-sm text-center flex-1">
<h2 class="text-2xl font-bold text-center pb-6">S'inscrire</h2> <h2 class="text-2xl font-bold text-center pb-6">S'inscrire</h2>
@@ -23,7 +23,7 @@
{{ form_row(registrationForm.telephone) }} {{ form_row(registrationForm.telephone) }}
{{ form_row(registrationForm.email) }} {{ form_row(registrationForm.email) }}
{{ form_row(registrationForm.plainPassword) }} {{ form_row(registrationForm.plainPassword) }}
<button class="bg-blue-500 hover:bg-blue-400 text-white font-bold py-2 px-4 border-b-4 border-blue-700 hover:border-blue-500 rounded mx-auto" type="submit">S'inscrire</button> <button class="btnRegister text-white font-bold py-2 px-4 border-b-4 rounded mx-auto" type="submit">S'inscrire</button>
{{ form_end(registrationForm) }} {{ form_end(registrationForm) }}
</div> </div>
</div> </div>