Admin could change password to users
This commit is contained in:
parent
583682106d
commit
ce9063b87d
4 changed files with 13 additions and 5 deletions
|
@ -19,6 +19,7 @@ public class UserGenerified {
|
|||
private String displayName;
|
||||
private List<UserRole> athorities;
|
||||
private List<UserRole> athoritiesLost;
|
||||
private String password;
|
||||
|
||||
public UserGenerified(User user, List<UserRole> allRolesList){
|
||||
this.id = user.getId();
|
||||
|
|
|
@ -87,13 +87,16 @@ public class ManageUsersController {
|
|||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public String updateRoles(UserGenerified userGenerified) {
|
||||
public String update(UserGenerified userGenerified) {
|
||||
User user = userRepository.findById(userGenerified.getId()).get();
|
||||
if (user == null)
|
||||
return "redirect:/manage_users";
|
||||
|
||||
user.setAuthorities(userGenerified.getAthorities());
|
||||
user.setDisplayname(userGenerified.getDisplayName());
|
||||
String password = userGenerified.getPassword().trim();
|
||||
if (! password.trim().isEmpty())
|
||||
user.setPassword(passwordEncoder.encode(userGenerified.getPassword()));
|
||||
userRepository.save(user);
|
||||
|
||||
return "redirect:/manage_users";
|
||||
|
|
|
@ -16,7 +16,6 @@ import ru.redrise.marinesco.User;
|
|||
import ru.redrise.marinesco.data.RolesRepository;
|
||||
import ru.redrise.marinesco.data.UserRepository;
|
||||
import ru.redrise.marinesco.settings.ApplicationSettings;
|
||||
import ru.redrise.marinesco.settings.KeyValueRepository;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<title>Marinesco - Manage users</title>
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
||||
<link rel="alternate icon" href="/favicon.png" type="image/png">
|
||||
<link rel="alternate icon" href="/favicon.png" type="image/png">
|
||||
<link rel="stylesheet" th:href="@{/styles/styles.css}" />
|
||||
</head>
|
||||
|
||||
|
@ -21,8 +21,12 @@
|
|||
<input type="hidden" th:value="${user.id}" name="id" />
|
||||
<input type="hidden" th:value="${user.name}" name="name" />
|
||||
<br />
|
||||
Display name:
|
||||
Display name:
|
||||
<input type="text" th:value="${user.displayName}" name="displayName" />
|
||||
<p>
|
||||
Password:
|
||||
<input type="password" name="password" />
|
||||
</p>
|
||||
<br /><br /><b>Roles:</b>
|
||||
<div th:each="athorities : ${user.athorities}">
|
||||
<input name="athorities" type="checkbox" th:value="${athorities.id}" th:checked="true" />
|
||||
|
@ -62,7 +66,8 @@
|
|||
<br />
|
||||
<b>Roles:</b>
|
||||
<br />
|
||||
<span class="validationError" th:if="${#fields.hasErrors('athorities')}" th:errors="*{athorities}"></span>
|
||||
<span class="validationError" th:if="${#fields.hasErrors('athorities')}"
|
||||
th:errors="*{athorities}"></span>
|
||||
<div th:each="athorities : ${rolesSet}">
|
||||
<input th:field="*{athorities}" type="checkbox" th:value="${athorities.id}" />
|
||||
<span th:text="${athorities.name}"></span><br />
|
||||
|
|
Loading…
Reference in a new issue