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
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
<br />
|
||||
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