Let admin edit all fields of customer

This commit is contained in:
Denis Natusch 2023-11-21 22:30:17 +01:00
parent b944d04b5d
commit 2515c17de5
No known key found for this signature in database
GPG key ID: 5E57BD8EDACFA985
2 changed files with 7 additions and 2 deletions

View file

@ -116,9 +116,10 @@ public class UserController {
@PostMapping("/customers/edit/{id}")
@PreAuthorize("hasRole('ADMIN')")
public String updateCustomer(@PathVariable("id") User user, @RequestParam String username, @RequestParam String address) {
public String updateCustomer(@PathVariable("id") User user, @RequestParam String fullName, @RequestParam String username, @RequestParam String address) {
user.setUsername(username);
user.setAddress(address);
user.setFullName(fullName);
userManagement.save(user);
return "redirect:/customers";
}

View file

@ -12,9 +12,13 @@
<label class="form-label" for="username">Nutzername</label>
<input class="form-control" type="text" name="username" th:value="${customer.username}"/>
</div>
<div class="mb-3">
<label class="form-label" for="fullName">Name</label>
<input class="form-control" type="fullName" name="fullName" th:value="${customer.fullName}"/>
</div>
<div class="mb-3">
<label class="form-label" for="address">Adresse</label>
<input class="form-control" type="text" name="address" th:value="${customer.address}"/>
<textarea class="form-control" name="address" th:text="${customer.address}" rows="3" required></textarea>
</div>
<button class="btn btn-primary" type="submit">Speichern</button>
</form>