fichier langue / bootstrap

This commit is contained in:
mepiphana2023
2024-04-24 12:15:04 +02:00
parent 3faaeffa70
commit 666416d2f3
6 changed files with 172 additions and 166 deletions

View File

@@ -34,9 +34,4 @@ public class LoginController {
return "redirect:/security/login?error";
}
}
@GetMapping("/logout")
public String logout(Model modele) {
return "security/logout";
}
}

View File

@@ -22,10 +22,15 @@ public class WebSecurityConfig{
.requestMatchers("/profil/**", "/article/new/**", "/article/update", "/article/delete").authenticated()
.requestMatchers("/admin").hasRole("ADMIN")
.anyRequest().authenticated())
.formLogin((form) -> form.loginPage("/login").defaultSuccessUrl("/", true))
.logout((logout) -> logout.clearAuthentication(true).invalidateHttpSession(true)
.deleteCookies("JSESSIONID").logoutSuccessUrl("/logout")
.logoutRequestMatcher(new AntPathRequestMatcher("/logout")).permitAll());
.formLogin((form) -> form
.loginPage("/login")
.defaultSuccessUrl("/", true))
.logout((logout) -> logout
.logoutUrl("/logout")
.logoutSuccessUrl("/accueil") // Redirection après déconnexion
.invalidateHttpSession(true)
.clearAuthentication(true)
.deleteCookies("JSESSIONID"));
return http.build();
}

View File

@@ -1,3 +1,44 @@
accueil.search.title = Rechercher un article par nom...
accueil.search.cat = Toutes les cat\u00e9gories
accueil.search.button = Recherche
profil.title = Mon profil
profil.button = Modifier
profil.pseudo = Pseudo:
profil.surname = Pr\u00e9nom:
profil.name = Nom:
profil.email = Email:
profil.phone = T\u00e9l\u00e9phone:
profil.street = Rue:
profil.postal = Code postal:
profil.city = Ville:
profil.credit = Cr\u00e9dits:
edit.profil.currentpassword = Mot de passe actuel:
edit.profil.newpassword = Nouveau mot de passe:
edit.profil.confirmnewpassword = Confirmation du nouveau mot de passe:
edit.profil.title = Modifier mon profil
edit.profil.button.edit = Enregistrer les modifications
edit.profil.button.del = Supprimer mon compte
login.title = Pour se Connecter :
login.id = Identifiant:
login.password = Mot de passe:
login.save = Se souvenir de moi
login.forgotpassword = Mot de passe oubli\u00e9
login.connection = Connexion
login.makecompte = Cr\u00e9er un compte
register.title = Mon profil
register.button = Modifier
register.pseudo = Pseudo:
register.surname = Pr\u00e9nom:
register.name = Nom:
register.email = Email:
register.phone = T\u00e9l\u00e9phone:
register.street = Rue:
register.postal = Code postal:
register.city = Ville:
register.credit = Cr\u00e9dits:
register.make = cr\u00e9er
register.cancel = annuler

View File

@@ -1,158 +1,123 @@
<!DOCTYPE html>
<html lang="fr" th:replace="~{modele-page :: layout('Modifier votre profile' , ~{::#link}, ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<html lang="fr" th:replace="~{modele-page :: layout('Modifier votre profil' , ~{::#link}, ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/fontawesome/css/all.css">
</head>
<body>
<div id="container-main">
<h1>Mon profil</h1>
<form th:action="@{/inscription/newUser}" method="post" th:object="${userProfile}">
<!--<div class="erreur-saisie" th:if="${#fields.hasErrors('*')}" >
<p th:text="#{index.erreurs}">Message d'erreur</p>
</div>-->
<!-- Champ pseudo-->
<div class="champ-saisie">
<label for="pseudo">Pseudo: </label>
<div>
<input type="text" th:field="*{pseudo}" id="pseudo" />
</div>
<span style="color: red;" th:if="${#fields.hasErrors('pseudo')}">
<div id="container-main" class="container mt-5">
<h1 th:text="#{edit.profil.title}"></h1>
<form th:action="@{/inscription/newUser}" method="post" th:object="${userProfile}" class="needs-validation" novalidate>
<div class="card">
<div class="card-body">
<!-- Iteration over form fields -->
<div class="mb-3">
<label for="pseudo" class="form-label" th:text="#{profil.pseudo}"></label>
<input type="text" class="form-control" th:field="*{pseudo}" id="pseudo" required>
<div th="if=${#fields.hasErrors('pseudo')}" class="invalid-feedback">
<ul>
<li th:each="erreur: ${#fields.errors('pseudo')}" th:text="${erreur}"></li>
<li th:each="err : ${#fields.errors('pseudo')}" th:text="${err}"></li>
</ul>
</span>
</div>
<!-- Champ prénom-->
<div class="champ-saisie">
<label for="prenom">Prénom: </label>
<div>
<input type="text" th:field="*{prenom}" id="prenom" />
</div>
<span style="color: red;" th:if="${#fields.hasErrors('prenom')}">
<div class="mb-3">
<label for="prenom" class="form-label" th:text="#{profil.surname}">:</label>
<input type="text" class="form-control" th:field="*{prenom}" id="prenom" required>
<div th="if=${#fields.hasErrors('prenom')}" class="invalid-feedback">
<ul>
<li th:each="erreur: ${#fields.errors('prenom')}" th:text="${erreur}"></li>
<li th:each="err : ${#fields.errors('prenom')}" th:text="${err}"></li>
</ul>
</span>
</div>
<!-- Champ nom-->
<div class="champ-saisie">
<label for="nom">Nom: </label>
<div>
<input type="text" th:field="*{nom}" id="nom" />
</div>
<span style="color: red;" th:if="${#fields.hasErrors('nom')}">
<div class="mb-3">
<label for="nom" class="form-label" th:text="#{profil.name}"></label>
<input type="text" class="form-control" th:field="*{nom}" id="nom" required>
<div th="if=${#fields.hasErrors('nom')}" class="invalid-feedback">
<ul>
<li th:each="erreur: ${#fields.errors('nom')}" th:text="${erreur}"></li>
<li th:each="err : ${#fields.errors('nom')}" th:text="${err}"></li>
</ul>
</span>
</div>
<!-- Champ email-->
<div class="champ-saisie">
<label for="email">Email: </label>
<div>
<input type="email" th:field="*{email}" id="email" />
</div>
<span style="color: red;" th:if="${#fields.hasErrors('email')}">
<div class="mb-3">
<label for="email" class="form-label" th:text="#{profil.email}" ></label>
<input type="email" class="form-control" th:field="*{email}" id="email" required>
<div th="if=${#fields.hasErrors('email')}" class="invalid-feedback">
<ul>
<li th:each="erreur: ${#fields.errors('email')}" th:text="${erreur}"></li>
<li th:each="err : ${#fields.errors('email')}" th:text="${err}"></li>
</ul>
</span>
</div>
<!-- Champ téléphone-->
<div class="champ-saisie">
<label for="telephone">Téléphone: </label>
<div>
<input type="text" th:field="*{telephone}" id="telephone" />
</div>
<span style="color: red;" th:if="${#fields.hasErrors('telephone')}">
<div class="mb-3">
<label for="telephone" class="form-label" th:text="#{profil.phone}"></label>
<input type="text" class="form-control" th:field="*{telephone}" id="telephone">
<div th="if=${#fields.hasErrors('telephone')}" class="invalid-feedback">
<ul>
<li th:each="erreur: ${#fields.errors('telephone')}" th:text="${erreur}"></li>
<li th:each="err : ${#fields.errors('telephone')}" th:text="${err}"></li>
</ul>
</span>
</div>
<!-- Champ Rue-->
<div class="champ-saisie">
<label for="rue">Rue: </label>
<div>
<input type="text" th:field="*{rue}" id="rue" />
</div>
<span style="color: red;" th:if="${#fields.hasErrors('rue')}">
<div class="mb-3">
<label for="rue" class="form-label" th:text="#{profil.street}"></label>
<input type="text" class="form-control" th:field="*{rue}" id="rue">
<div th="if=${#fields.hasErrors('rue')}" class="invalid-feedback">
<ul>
<li th:each="erreur: ${#fields.errors('rue')}" th:text="${erreur}"></li>
<li th:each="err : ${#fields.errors('rue')}" th:text="${err}"></li>
</ul>
</span>
</div>
<!-- Champ Code postal-->
<div class="champ-saisie">
<label for="code_postal">Code postal: </label>
<div>
<input type="text" th:field="*{code_postal}" id="code_postal" />
</div>
<span style="color: red;" th:if="${#fields.hasErrors('code_postal')}">
<div class="mb-3">
<label for="code_postal" class="form-label" th:text="#{profil.postal}"></label>
<input type="text" class="form-control" th:field="*{code_postal}" id="code_postal">
<div th="if=${#fields.hasErrors('code_postal')}" class="invalid-feedback">
<ul>
<li th:each="erreur: ${#fields.errors('code_postal')}" th:text="${erreur}"></li>
<li th:each="err : ${#fields.errors('code_postal')}" th:text="${err}"></li>
</ul>
</span>
</div>
<!-- Champ Ville-->
<div class="champ-saisie">
<label for="code_postal">Ville: </label>
<div>
<input type="text" th:field="*{ville}" id="ville" />
</div>
<span style="color: red;" th:if="${#fields.hasErrors('ville')}">
<div class="mb-3">
<label for="ville" class="form-label" th:text="#{profil.city}"></label>
<input type="text" class="form-control" th:field="*{ville}" id="ville">
<div th="if=${#fields.hasErrors('ville')}" class="invalid-feedback">
<ul>
<li th:each="erreur: ${#fields.errors('ville')}" th:text="${erreur}"></li>
<li th:each="err : ${#fields.errors('ville')}" th:text="${err}"></li>
</ul>
</span>
</div>
<!-- Champ Mot de passe actuel-->
<div class="champ-saisie">
<label for="currentPassword">Mot de passe actuel: </label>
<div>
<input type="password" th:field="*{currentPassword}" name="currentPassword" id="currentPassword" />
</div>
<span style="color: red;" th:if="${#fields.hasErrors('currentPassword')}">
<ul>
<li th:each="erreur: ${#fields.errors('currentPassword')}" th:text="${erreur}"></li>
</ul>
</span>
<div class="mb-3">
<label for="currentPassword" class="form-label" th:text="#{edit.profil.currentpassword}"></label>
<input type="password" class="form-control" th:field="*{currentPassword}" id="currentPassword">
</div>
<!-- Champ Nouveau mot de passe-->
<div class="champ-saisie">
<label for="newPassword">Nouveau mot de passe: </label>
<div>
<input type="password" th:field="*{newPassword}" name="newPassword" id="newPassword" />
<div class="mb-3">
<label for="newPassword" class="form-label" th:text="#{edit.profil.newpassword}"></label>
<input type="password" class="form-control" th:field="*{newPassword}" id="newPassword">
</div>
<span style="color: red;" th:if="${#fields.hasErrors('newPassword')}">
<ul>
<li th:each="erreur: ${#fields.errors('newPassword')}" th:text="${erreur}"></li>
</ul>
</span>
<div class="mb-3">
<label for="confirmPassword" class="form-label" th:text="#{edit.profil.confirmnewpassword}"></label>
<input type="password" class="form-control" id="confirmPassword" th:field="*{confirmPassword}">
</div>
<!-- Champ Confirmation du nouveau mot de passe-->
<div class="champ-saisie">
<label for="confirmPassword">Confirmation du nouveau mot de passe: </label>
<div>
<input type="password" th:field="*{confirmPassword}" id="confirmPassword" />
<div class="mb-3">
<span th:text="#{profil.credit}"></span> <span th:text="${userProfile.credit}"></span>
</div>
<input type="hidden" th:field="*{id}" id="userId" th:value="${userProfile.id}">
<button type="submit" class="btn btn-primary" th:text="#{edit.profil.button.edit}"></button>
</div>
<span style="color: red;" th:if="${#fields.hasErrors('confirmPassword')}">
<ul>
<li th:each="erreur: ${#fields.errors('confirmPassword')}" th:text="${erreur}"></li>
</ul>
</span>
</div>
<div>Crédits: <span th:text="${userProfile.credit}"></span></div>
<!-- Input cacher qui permet de stocker l'id du compte utilisateur à mettre à jour -->
<input type="hidden" id="userId" name="userId" th:field="*{id}" th:value="${userProfile.id}" />
<input type="submit" value="Enregistrer"/>
</form>
<form th:action="@{/profil/delete}" method="post">
<button type="submit">Supprimer mon compte</button>
<form th:action="@{/profil/delete}" method="post" class="mt-4">
<button type="submit" class="btn btn-danger" th:text="#{edit.profil.button.del}"></button>
</form>
</div>
<script src="js/bootstrap/bootstrap.min.js"></script>
<script src="js/bootstrap/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@@ -28,7 +28,7 @@
<a class="nav-link" href="/profil">Mon profile</a>
</li>
<li class="nav-item" th:if="${#authorization.expression('hasRole(''MEMBRE'')')}">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true" >Déconnection</a>
<a class="nav-link disabled" th:href="@{/logout}" tabindex="-1" aria-disabled="true" >Déconnection</a>
</li>
<li class="nav-item" th:if="${#authentication.principal == 'anonymousUser'}">
<a class="btn btn-primary" href="/login" role="button" style="background-color: #1B4463;">S'inscrire / Se connecter</a>

View File

@@ -9,49 +9,49 @@
<div class="col-md-6 offset-md-3">
<div class="card">
<div class="card-header">
<h4>Mon profil</h4>
<h4 th:text="#{profil.title}"></h4>
</div>
<div class="card-body">
<ul class="list-group">
<li class="list-group-item">
<strong><label class="col-form-label">Pseudo:</label></strong>
<strong><label class="col-form-label" th:text="#{profil.pseudo}"></label></strong>
<span th:text="${userProfile.pseudo}"></span>
</li>
<li class="list-group-item">
<strong><label class="col-form-label">Prénom:</label></strong>
<strong><label class="col-form-label" th:text="#{profil.surname}"></label></strong>
<span th:text="${userProfile.prenom}"></span>
</li>
<li class="list-group-item">
<strong><label class="col-form-label">Nom:</label></strong>
<strong><label class="col-form-label" th:text="#{profil.name}"></label></strong>
<span th:text="${userProfile.nom}"></span>
</li>
<li class="list-group-item">
<strong><label class="col-form-label">Email:</label></strong>
<strong><label class="col-form-label" th:text="#{profil.email}"></label></strong>
<span th:text="${userProfile.email}"></span>
</li>
<li class="list-group-item">
<strong><label class="col-form-label">Téléphone:</label></strong>
<strong><label class="col-form-label" th:text="#{profil.phone}"></label></strong>
<span th:text="${userProfile.telephone}"></span>
</li>
<li class="list-group-item">
<strong><label class="col-form-label">Rue:</label></strong>
<strong><label class="col-form-label" th:text="#{profil.street}"></label></strong>
<span th:text="${userProfile.rue}"></span>
</li>
<li class="list-group-item">
<strong><label class="col-form-label">Code postal:</label></strong>
<strong><label class="col-form-label" th:text="#{profil.postal}"></label></strong>
<span th:text="${userProfile.code_postal}"></span>
</li>
<li class="list-group-item">
<strong><label class="col-form-label">Ville:</label></strong>
<strong><label class="col-form-label" th:text="#{profil.city}">Ville:</label></strong>
<span th:text="${userProfile.ville}"></span>
</li>
<li class="list-group-item">
<strong><label class="col-form-label">Crédits:</label></strong>
<strong><label class="col-form-label" th:text="#{profil.credit}"></label></strong>
<span th:text="${userProfile.credit}"></span>
</li>
</ul>
<form th:action="@{/profil/edit}" method="post" class="mt-3">
<button type="submit" class="btn btn-primary">Modifier</button>
<button type="submit" class="btn btn-primary" th:text="#{profil.button}"></button>
</form>
</div>
</div>