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 String displayName;
|
||||||
private List<UserRole> athorities;
|
private List<UserRole> athorities;
|
||||||
private List<UserRole> athoritiesLost;
|
private List<UserRole> athoritiesLost;
|
||||||
|
private String password;
|
||||||
|
|
||||||
public UserGenerified(User user, List<UserRole> allRolesList){
|
public UserGenerified(User user, List<UserRole> allRolesList){
|
||||||
this.id = user.getId();
|
this.id = user.getId();
|
||||||
|
|
|
@ -87,13 +87,16 @@ public class ManageUsersController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public String updateRoles(UserGenerified userGenerified) {
|
public String update(UserGenerified userGenerified) {
|
||||||
User user = userRepository.findById(userGenerified.getId()).get();
|
User user = userRepository.findById(userGenerified.getId()).get();
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return "redirect:/manage_users";
|
return "redirect:/manage_users";
|
||||||
|
|
||||||
user.setAuthorities(userGenerified.getAthorities());
|
user.setAuthorities(userGenerified.getAthorities());
|
||||||
user.setDisplayname(userGenerified.getDisplayName());
|
user.setDisplayname(userGenerified.getDisplayName());
|
||||||
|
String password = userGenerified.getPassword().trim();
|
||||||
|
if (! password.trim().isEmpty())
|
||||||
|
user.setPassword(passwordEncoder.encode(userGenerified.getPassword()));
|
||||||
userRepository.save(user);
|
userRepository.save(user);
|
||||||
|
|
||||||
return "redirect:/manage_users";
|
return "redirect:/manage_users";
|
||||||
|
|
|
@ -16,7 +16,6 @@ import ru.redrise.marinesco.User;
|
||||||
import ru.redrise.marinesco.data.RolesRepository;
|
import ru.redrise.marinesco.data.RolesRepository;
|
||||||
import ru.redrise.marinesco.data.UserRepository;
|
import ru.redrise.marinesco.data.UserRepository;
|
||||||
import ru.redrise.marinesco.settings.ApplicationSettings;
|
import ru.redrise.marinesco.settings.ApplicationSettings;
|
||||||
import ru.redrise.marinesco.settings.KeyValueRepository;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<head>
|
<head>
|
||||||
<title>Marinesco - Manage users</title>
|
<title>Marinesco - Manage users</title>
|
||||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
<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}" />
|
<link rel="stylesheet" th:href="@{/styles/styles.css}" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@
|
||||||
<br />
|
<br />
|
||||||
Display name:
|
Display name:
|
||||||
<input type="text" th:value="${user.displayName}" name="displayName" />
|
<input type="text" th:value="${user.displayName}" name="displayName" />
|
||||||
|
<p>
|
||||||
|
Password:
|
||||||
|
<input type="password" name="password" />
|
||||||
|
</p>
|
||||||
<br /><br /><b>Roles:</b>
|
<br /><br /><b>Roles:</b>
|
||||||
<div th:each="athorities : ${user.athorities}">
|
<div th:each="athorities : ${user.athorities}">
|
||||||
<input name="athorities" type="checkbox" th:value="${athorities.id}" th:checked="true" />
|
<input name="athorities" type="checkbox" th:value="${athorities.id}" th:checked="true" />
|
||||||
|
@ -62,7 +66,8 @@
|
||||||
<br />
|
<br />
|
||||||
<b>Roles:</b>
|
<b>Roles:</b>
|
||||||
<br />
|
<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}">
|
<div th:each="athorities : ${rolesSet}">
|
||||||
<input th:field="*{athorities}" type="checkbox" th:value="${athorities.id}" />
|
<input th:field="*{athorities}" type="checkbox" th:value="${athorities.id}" />
|
||||||
<span th:text="${athorities.name}"></span><br />
|
<span th:text="${athorities.name}"></span><br />
|
||||||
|
|
Loading…
Reference in a new issue