1

fix rename errors

Co-authored-by: Christoph <tobi@urpost.de>
This commit is contained in:
Christoph
2020-03-19 00:20:14 +01:00
parent fdd9d44aac
commit 2192751a01
7 changed files with 18 additions and 14 deletions

View File

@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.annotation.SessionScope;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ResponseStatusException;
import javax.annotation.security.RolesAllowed;
import java.io.IOException;
@ -144,8 +143,7 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
@GetMapping("/details/{id}")
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @PathVariable("id") Long groupId) throws EventException, ResponseStatusException {
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @PathVariable("id") Long groupId) throws EventException {
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
Group group = userService.getGroupById(groupId);
Account account = keyCloakService.createAccountFromPrincipal(token);
@ -169,7 +167,7 @@ public class Gruppen2Controller {
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
Group group = userService.getGroupById(groupId);
if (group.getMembers().contains(user)) {
return "errorRenameLater"; //hier soll eigentlich auf die bereits beigetretene Gruppe weitergeleitet werden
return "error"; //hier soll eigentlich auf die bereits beigetretene Gruppe weitergeleitet werden
}
controllerService.addUser(account, groupId);
return "redirect:/gruppen2/";

View File

@ -21,6 +21,6 @@ public class MopsController {
@GetMapping("*")
public String defaultLink() {
return "errorRenameLater";
return "error";
}
}

View File

@ -21,10 +21,12 @@ public class UpdateRoleEvent extends Event {
super(groupId, userId);
this.newRole = newRole;
}
@Override
public void applyEvent(Group group) throws UserNotFoundException {
if (group.getRoles().containsKey(this.userId)) {
group.getRoles().put(this.userId, this.newRole);
return;
}
throw new UserNotFoundException(this.getClass().toString());

View File

@ -7,9 +7,9 @@ import java.util.Set;
@Value
public class Account {
String name; //user_id
String email;
String image;
String name; //user_id
String givenname;
String familyname;
Set<String> roles;

View File

@ -120,7 +120,11 @@ public class ControllerService {
user = member;
}
}
assert user != null;
if (user == null) {
throw new UserNotFoundException(this.getClass().toString());
}
DeleteUserEvent deleteUserEvent = new DeleteUserEvent(groupId, user.getId());
eventService.saveEvent(deleteUserEvent);
}