#13 -- Add buttons
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 1m12s

This commit is contained in:
Anton Romanov 2025-02-18 14:02:43 +04:00
parent 63ec2cc289
commit ecf5e1fab9
5 changed files with 78 additions and 58 deletions

View File

@ -19,6 +19,7 @@ public class SecurityConfiguration {
private final String[] permittedUrls = new String[]{
"/login", "/index", "/user/register",
"/public/**", "/organizers", "/webjars/**",
"/error", "/register",
"/h2-console/*", "/h2-console",
"/css/**", "/js/**", "/img/**",
"/templates/**", "/webjars/**"};

View File

@ -3,6 +3,7 @@ package ru.ulstu.fc.config;
import nz.net.ultraq.thymeleaf.layoutdialect.LayoutDialect;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.thymeleaf.extras.springsecurity6.dialect.SpringSecurityDialect;
import org.thymeleaf.spring6.SpringTemplateEngine;
import org.thymeleaf.templateresolver.ITemplateResolver;
@ -10,10 +11,11 @@ import org.thymeleaf.templateresolver.ITemplateResolver;
public class TemplateConfiguration {
@Bean
public SpringTemplateEngine templateEngine(ITemplateResolver templateResolver) {
public SpringTemplateEngine templateEngine(ITemplateResolver templateResolver, SpringSecurityDialect sec) {
final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.addTemplateResolver(templateResolver);
templateEngine.addDialect(new LayoutDialect());
templateEngine.addDialect(sec);
return templateEngine;
}
}

View File

@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="ru"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml">
<html lang="ru" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity6">
<head>
<meta charset="UTF-8" />
<title>Нечеткий контроллер</title>
@ -12,6 +13,7 @@
<link rel="stylesheet" href="/webjars/bootstrap-select/1.13.8/css/bootstrap-select.min.css" />
<link rel="stylesheet" href="/webjars/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light" layout:fragment="navbar">
<a class="navbar-brand" href="/">Нечеткий контроллер</a>
@ -31,6 +33,17 @@
<li class="nav-item">
<a class="nav-link" href="/swagger-ui/index.html">API</a>
</li>
<li>
<div sec:authorize="isAuthenticated()">
<a class="nav-link" href="/logout">
<span sec:authentication="name">Bob</span>
(Выход)</a>
</div>
<div sec:authorize="!isAuthenticated()">
<a class="nav-link" href="/login">Вход</a>
</div>
</li>
</ul>
</div>
</nav>
@ -54,4 +67,5 @@
</div>
</div>
</body>
</html>

View File

@ -24,7 +24,8 @@
<input type="password" name="password" id="password" class="form-control"
placeholder="Пароль" required="true"/>
</div>
<button type="submit" class="btn btn-outline-dark btn-block">Войти</button>
<button type="submit" class="btn btn-outline-dark">Войти</button>
<a href="/user/register" class="btn btn-outline-dark">Регистрация</a>
</fieldset>
</form>
</div>

View File

@ -1,26 +1,28 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{default}">
<div class="container" layout:fragment="content">
<h1 th:text="#{label.form.title}">form</h1>
<h3>Регистрация</h3>
<form action="/user/register" th:object="${user}" method="POST" enctype="utf8">
<div>
<label th:text="#{label.user.firstName}">first</label>
<input th:field="*{login}" />
<div class="form-group">
<label for="login">Логин</label>
<input th:field="*{login}" id="login" type="text" required class="form-control"
placeholder="Логин пользователя">
<p th:each="error: ${#fields.errors('login')}" th:text="${error}">Validation error</p>
</div>
<div>
<label th:text="#{label.user.password}">password</label>
<input type="password" th:field="*{password}" />
<div class="form-group">
<label for="password">Пароль</label>
<input th:field="*{password}" id="password" type="text" required class="form-control"
placeholder="Пароль">
<p th:each="error : ${#fields.errors('password')}" th:text="${error}">Validation error</p>
</div>
<div>
<label th:text="#{label.user.confirmPass}">confirm</label>
<input type="password" th:field="*{matchingPassword}" />
<div class="form-group">
<label for="confirmPass">Подтверждение пароля</label>
<input id = "confirmPass" type="password" th:field="*{matchingPassword}" required class="form-control"
placeholder="Подтверждение пароля"/>
</div>
<button type="submit" th:text="#{label.form.submit}">submit</button>
<button type="submit" class="btn btn-outline-dark">Зарегистрировать</button>
<a href="/login" class="btn btn-outline-dark">Вернуться на страницу входа</a>
</form>
<a th:href="@{/login.html}" th:text="#{label.form.loginLink}">login</a>
</div>
</body>