Неправильно сохраняет юзеров

This commit is contained in:
DyCTaTOR 2024-06-05 00:22:12 +04:00
parent dbff5ad51e
commit 845d28ad0a
7 changed files with 3141 additions and 33 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,8 @@ public class SecurityConfiguration {
.anyRequest().authenticated()); .anyRequest().authenticated());
httpSecurity.formLogin(formLogin -> formLogin httpSecurity.formLogin(formLogin -> formLogin
.loginPage(Constants.LOGIN_URL)); .loginPage(Constants.LOGIN_URL)
.defaultSuccessUrl("/news", true));
httpSecurity.rememberMe(rememberMe -> rememberMe.key("uniqueAndSecret")); httpSecurity.rememberMe(rememberMe -> rememberMe.key("uniqueAndSecret"));

View File

@ -73,5 +73,4 @@ public class EntrysDataSignupController {
userService.create(toEntity(user)); userService.create(toEntity(user));
return Constants.REDIRECT_VIEW + Constants.LOGIN_URL + "?signup"; return Constants.REDIRECT_VIEW + Constants.LOGIN_URL + "?signup";
} }
} }

View File

@ -16,11 +16,11 @@ import jakarta.persistence.Table;
public class EntrysDataEntity extends BaseEntity { public class EntrysDataEntity extends BaseEntity {
@Column(nullable = false, unique = true, length = 30) @Column(nullable = false, unique = true, length = 30)
private String login; private String login;
@Column(nullable = false, length = 25) @Column(nullable = false, length = 60)
private String password; private String password;
private EntrysDataRole role; private EntrysDataRole role;
@ManyToOne @ManyToOne
@JoinColumn(name = "departmentId", nullable = false) @JoinColumn(name = "departmentId", nullable = true)
private DepartmentEntity department; private DepartmentEntity department;
public EntrysDataEntity() { public EntrysDataEntity() {

View File

@ -16,35 +16,40 @@
<body class="h-100 d-flex flex-column"> <body class="h-100 d-flex flex-column">
<nav class="navbar navbar-expand-md my-navbar" data-bs-theme="dark"> <nav class="navbar navbar-expand-md my-navbar" data-bs-theme="dark">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="/"> <a class="navbar-brand" href="/news">
<i></i> <i></i>
UlSTU UlSTU
</a> </a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#main-navbar" <th:block sec:authorize="isAuthenticated()" th:with="userName=${#authentication.name}">
aria-controls="main-navbar" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#main-navbar"
<span class="navbar-toggler-icon"></span> aria-controls="main-navbar" aria-expanded="false" aria-label="Toggle navigation">
</button> <span class="navbar-toggler-icon"></span>
<div class="collapse navbar-collapse" id="main-navbar"> </button>
<ul class="navbar-nav me-auto link" th:with="activeLink=${#objects.nullSafe(servletPath, '')}"> <div class="collapse navbar-collapse" id="main-navbar">
<a class="nav-link" href="/news" th:classappend="${activeLink.startsWith('/news') ? 'active' : ''}"> <ul class="navbar-nav me-auto link" th:with="activeLink=${#objects.nullSafe(servletPath, '')}">
Новости <a class="nav-link" href="/news"
</a> th:classappend="${activeLink.startsWith('/news') ? 'active' : ''}">
<a class="nav-link" href="/directions" Новости
th:classappend="${activeLink.startsWith('/directions') ? 'active' : ''}"> </a>
Направления <a class="nav-link" href="/directions"
</a> th:classappend="${activeLink.startsWith('/directions') ? 'active' : ''}">
<a class="nav-link" href="/departments" Направления
th:classappend="${activeLink.startsWith('/departments') ? 'active' : ''}"> </a>
Кафедры <th:block sec:authorize="hasRole('ADMIN')">
</a> <a class="nav-link" href="/admin/departments"
<a class="nav-link" href="/users" th:classappend="${activeLink.startsWith('/departments') ? 'active' : ''}">
th:classappend="${activeLink.startsWith('/users') ? 'active' : ''}"> Кафедры
Пользователи </a>
</a> <a class="nav-link" href="/admin/users"
</ul> th:classappend="${activeLink.startsWith('/users') ? 'active' : ''}">
<ul class="navbar-nav"> Пользователи
</ul> </a>
</div> </th:block>
</ul>
<ul class="navbar-nav">
</ul>
</div>
</th:block>
</div> </div>
</nav> </nav>
<main class="container-fluid p-2" layout:fragment="content"> <main class="container-fluid p-2" layout:fragment="content">

View File

@ -43,7 +43,7 @@
<h2 th:case="0">Данные отсутствуют</h2> <h2 th:case="0">Данные отсутствуют</h2>
<th:block th:case="*"> <th:block th:case="*">
<div> <div>
<a th:href="@{/news/edit/(page=${page})}" class="btn btn-danger mt-1">Добавить новость</a> <a th:href="@{/admin/news/edit/(page=${page})}" class="btn btn-danger mt-1">Добавить новость</a>
</div> </div>
<div class="row"> <div class="row">
<div class="col mt-4 colStyle" th:each="newItem : ${items}"> <div class="col mt-4 colStyle" th:each="newItem : ${items}">
@ -56,12 +56,12 @@
</span> </span>
</div> </div>
<div class="forButtons"> <div class="forButtons">
<form th:action="@{/news/edit/{id}(id=${newItem.id})}" method="get"> <form th:action="@{/admin/news/edit/{id}(id=${newItem.id})}" method="get">
<input type="hidden" th:name="page" th:value="${page}"> <input type="hidden" th:name="page" th:value="${page}">
<button type="submit" class="btn btn-link button-link"> <button type="submit" class="btn btn-link button-link">
<i class="fa fa-edit">Изменить</i> <i class="fa fa-edit">Изменить</i>
</form> </form>
<form th:action="@{/news/delete/{id}(id=${newItem.id})}" method="post"> <form th:action="@{/admin/news/delete/{id}(id=${newItem.id})}" method="post">
<input type="hidden" th:name="page" th:value="${page}"> <input type="hidden" th:name="page" th:value="${page}">
<button type="submit" class="btn btn-link button-link" <button type="submit" class="btn btn-link button-link"
onclick="return confirm('Вы уверены?')"> onclick="return confirm('Вы уверены?')">