Fixed login page and workflow
This commit is contained in:
parent
90ccb8a00c
commit
4f3814bd7e
@ -33,6 +33,7 @@ dependencies {
|
|||||||
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
|
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||||
|
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.3.RELEASE'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
implementation 'org.springframework:spring-jdbc'
|
implementation 'org.springframework:spring-jdbc'
|
||||||
implementation 'org.flywaydb:flyway-core:11.3.2'
|
implementation 'org.flywaydb:flyway-core:11.3.2'
|
||||||
|
|||||||
14
src/main/java/com/bernard/misael/ThymeleafConfig.java
Normal file
14
src/main/java/com/bernard/misael/ThymeleafConfig.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.bernard.misael;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.thymeleaf.extras.springsecurity6.dialect.SpringSecurityDialect;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ThymeleafConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SpringSecurityDialect springSecurityDialect(){
|
||||||
|
return new SpringSecurityDialect();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -43,13 +43,7 @@ public class AuthController {
|
|||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public String index(Model model) {
|
public String index(Model model) {
|
||||||
if(SecurityContextHolder.getContext().getAuthentication().getPrincipal() instanceof org.springframework.security.core.userdetails.User){
|
|
||||||
org.springframework.security.core.userdetails.User user
|
|
||||||
= (org.springframework.security.core.userdetails.User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
|
||||||
model.addAttribute("username", user.getUsername());
|
|
||||||
}else{
|
|
||||||
model.addAttribute("username", "no-one");
|
|
||||||
}
|
|
||||||
return "index";
|
return "index";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,8 @@
|
|||||||
package com.bernard.misael.web;
|
package com.bernard.misael.web;
|
||||||
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import com.bernard.misael.service.dto.UserDto;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
|
||||||
@ -21,6 +17,7 @@ public class QuestionsController {
|
|||||||
public String getQuizz() {
|
public String getQuizz() {
|
||||||
return "quizz.html";
|
return "quizz.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/forms")
|
@GetMapping("/forms")
|
||||||
/*
|
/*
|
||||||
* List all forms started or finished by the user
|
* List all forms started or finished by the user
|
||||||
|
|||||||
@ -50,6 +50,7 @@ main{
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
color: #96c7e8;
|
color: #96c7e8;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
.button a{
|
.button a{
|
||||||
position: fixed;
|
position: fixed;
|
||||||
@ -62,3 +63,14 @@ main{
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
box-shadow: rgba(0, 0, 0, 0.15);
|
box-shadow: rgba(0, 0, 0, 0.15);
|
||||||
}
|
}
|
||||||
|
div.alert {
|
||||||
|
background: #FFDDEE;
|
||||||
|
font-size: 20px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.welcome{
|
||||||
|
color: #fff;
|
||||||
|
font-size: 20px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
@ -1,10 +1,13 @@
|
|||||||
<nav>
|
<nav>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="logo"><a href="#">Misael-Q</a></div>
|
<div class="logo"><a href="/">Misael</a></div>
|
||||||
|
<div class="welcome" sec:authorize="isAuthenticated()">Logged in as <span sec:authentication="name"/></div>
|
||||||
<ul class="menu">
|
<ul class="menu">
|
||||||
<li><a href="/questions/quizz">Quizz</a></li>
|
<li><a href="/questions/quizz">Quizz</a></li>
|
||||||
<li><a href="/questions/forms">Forms</a></li>
|
<li><a href="/questions/forms">Forms</a></li>
|
||||||
<li><a href="/login">Login</a></li>
|
<li sec:authorize="isAnonymous()"><a href="/login">Log in</a></li>
|
||||||
|
<li sec:authorize="isAuthenticated()"><a href="/logout">Log out</div></a></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@ -7,7 +7,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div th:replace="~{header}"/>
|
<div th:replace="~{header}"/>
|
||||||
<main>
|
<main>
|
||||||
Logged in as <div th:text="${username}"></div>
|
Youhou ! (Y a rien ici)
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<label for="password">Mot de passe :</label>
|
<label for="password">Mot de passe :</label>
|
||||||
<input type="password" id="password" name="password"/>
|
<input type="password" id="password" name="password"/>
|
||||||
<br/>
|
<br/>
|
||||||
<input id="connect" type="submit">Se connecter</input>
|
<input id="connect" type="submit" value="Se connecter"/>
|
||||||
</form>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user