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-thymeleaf'
|
||||
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:spring-jdbc'
|
||||
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("/")
|
||||
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";
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
package com.bernard.misael.web;
|
||||
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.bernard.misael.service.dto.UserDto;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
|
||||
@ -21,6 +17,7 @@ public class QuestionsController {
|
||||
public String getQuizz() {
|
||||
return "quizz.html";
|
||||
}
|
||||
|
||||
@GetMapping("/forms")
|
||||
/*
|
||||
* List all forms started or finished by the user
|
||||
|
||||
@ -50,6 +50,7 @@ main{
|
||||
justify-content: center;
|
||||
color: #96c7e8;
|
||||
font-size: 24px;
|
||||
flex-direction: column;
|
||||
}
|
||||
.button a{
|
||||
position: fixed;
|
||||
@ -62,3 +63,14 @@ main{
|
||||
border-radius: 6px;
|
||||
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>
|
||||
<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">
|
||||
<li><a href="/questions/quizz">Quizz</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>
|
||||
</div>
|
||||
</nav>
|
||||
@ -7,7 +7,7 @@
|
||||
<body>
|
||||
<div th:replace="~{header}"/>
|
||||
<main>
|
||||
Logged in as <div th:text="${username}"></div>
|
||||
Youhou ! (Y a rien ici)
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@ -25,7 +25,7 @@
|
||||
<label for="password">Mot de passe :</label>
|
||||
<input type="password" id="password" name="password"/>
|
||||
<br/>
|
||||
<input id="connect" type="submit">Se connecter</input>
|
||||
<input id="connect" type="submit" value="Se connecter"/>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user