Connexion page
This commit is contained in:
@@ -23,6 +23,11 @@ dependencies {
|
|||||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
|
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
|
||||||
implementation 'org.mariadb.jdbc:mariadb-java-client:2.2.0'
|
implementation 'org.mariadb.jdbc:mariadb-java-client:2.2.0'
|
||||||
|
//Securité
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||||
|
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
||||||
|
testImplementation 'org.springframework.security:spring-security-test'
|
||||||
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('test') {
|
tasks.named('test') {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
public class AccueilController {
|
public class AccueilController {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AccueilController.class);
|
private static final Logger logger = LoggerFactory.getLogger(AccueilController.class);
|
||||||
|
|
||||||
private ArticleService articleService;
|
private ArticleService articleService;
|
||||||
|
|
||||||
public AccueilController(ArticleService articleService) {
|
public AccueilController(ArticleService articleService) {
|
||||||
@@ -22,10 +21,13 @@ public class AccueilController {
|
|||||||
|
|
||||||
@GetMapping({"/", "/accueil"})
|
@GetMapping({"/", "/accueil"})
|
||||||
public String viewAccueil(Model model) {
|
public String viewAccueil(Model model) {
|
||||||
|
|
||||||
model.addAttribute("articles", articleService.findAllArticle());
|
model.addAttribute("articles", articleService.findAllArticle());
|
||||||
|
|
||||||
return "accueil";
|
return "accueil";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/login")
|
||||||
|
public String login(Model modele) {
|
||||||
|
return "login";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,10 @@ public class WebSecurityConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
http.authorizeHttpRequests((requests) -> requests.requestMatchers("/", "/films", "/filmotheque", "/film").permitAll()
|
http.authorizeHttpRequests((requests) -> requests.requestMatchers("/", "/accueil").permitAll()
|
||||||
.requestMatchers("/filmLogout", "/login").permitAll()
|
.requestMatchers("/accueil", "/login", "/inscription").permitAll()
|
||||||
.requestMatchers("/css/**", "/images/**").permitAll()
|
.requestMatchers("/css/**", "/images/**", "/assets/**", "/img/**", "/js/**").permitAll()
|
||||||
.requestMatchers("/genres").hasRole("ADMIN")
|
.requestMatchers("/admin").hasRole("ADMIN")
|
||||||
.requestMatchers("/ajoutFilm")
|
|
||||||
.hasAnyRole("MEMBRE", "ADMIN")
|
|
||||||
.anyRequest().authenticated())
|
.anyRequest().authenticated())
|
||||||
.formLogin((form) -> form.loginPage("/login").defaultSuccessUrl("/", true))
|
.formLogin((form) -> form.loginPage("/login").defaultSuccessUrl("/", true))
|
||||||
.logout((logout) -> logout.clearAuthentication(true).invalidateHttpSession(true)
|
.logout((logout) -> logout.clearAuthentication(true).invalidateHttpSession(true)
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr" th:replace="~{modele-page :: layout('Accueil',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
|
<html lang="fr" th:replace="~{modele-page :: layout('Accueil - ENI-Enchères',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Accueil</title>
|
<title>Accueil</title>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
<div class="d-flex justify-content-between align-items-center">
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
<div>
|
<div>
|
||||||
<h6>Prix de vente: <span th:text="${article.prixVente}"></span> €</h6>
|
<h6>Prix de vente: <span th:text="${article.prixVente}"></span> €</h6>
|
||||||
<h6 class="text-muted">Fin de l'enchere: <span th:text="${#dates.format(article.dateFinEnch, 'dd/MM/yyyy')}"></span> €</h6>
|
<h6 class="text-muted">Fin de l'enchere: <span th:text="${#dates.format(article.dateFinEnch, 'dd/MM/yyyy')}"></span></h6>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
23
src/main/resources/templates/login.html
Normal file
23
src/main/resources/templates/login.html
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr" th:replace="~{modele-page :: layout('Login',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container-main">
|
||||||
|
<h2>Pour se Connecter :</h2>
|
||||||
|
<br>
|
||||||
|
<form th:action="@{/login}" method="post">
|
||||||
|
<div><label>Identifiant: <input type="text" name="username"/> </label></div>
|
||||||
|
<div><label>Mot de passe: <input type="password" name="password"/> </label></div>
|
||||||
|
<div><input type="submit" value="Connexion"/></div>
|
||||||
|
</form>
|
||||||
|
<div th:if="${param.error}">
|
||||||
|
Identifiant ou mot de passe incorrect
|
||||||
|
</div>
|
||||||
|
<div th:if="${param.logout}">
|
||||||
|
Vous avez été déconnecté
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>[[${title}]]</title>
|
<title>[[${title}]]</title>
|
||||||
<link rel="icon" th:href="@{favicon.ico}" />
|
<link rel="icon" th:href="@{img/favicon.ico}" />
|
||||||
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet">
|
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet">
|
||||||
<link href="assets/bootstrap-icons/bootstrap-icons.min.css" rel="stylesheet">
|
<link href="assets/bootstrap-icons/bootstrap-icons.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
<header>
|
<header>
|
||||||
<nav class="navbar navbar-expand-lg navbar navbar-dark bg-dark navbar-">
|
<nav class="navbar navbar-expand-lg navbar navbar-dark bg-dark navbar-">
|
||||||
<a class="navbar-brand" href="#">
|
<a class="navbar-brand" href="#">
|
||||||
<img src="logo.png" width="70" height="70" alt="Logo">
|
<img src="img/logo.png" width="70" height="70" alt="Logo">
|
||||||
</a>
|
</a>
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
|||||||
Reference in New Issue
Block a user