fix GroupDelete
Co-Authored-By: Talha Caliskan <killerber4t@users.noreply.github.com>
This commit is contained in:
@ -8,8 +8,11 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
public class Gruppen2Config {
|
||||
|
||||
@Autowired
|
||||
GroupService groupService;
|
||||
@Autowired
|
||||
EventService eventService;
|
||||
final GroupService groupService;
|
||||
final EventService eventService;
|
||||
|
||||
public Gruppen2Config(GroupService groupService, EventService eventService) {
|
||||
this.groupService = groupService;
|
||||
this.eventService = eventService;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,15 +43,15 @@ public class Gruppen2Controller {
|
||||
private final UserService userService;
|
||||
private final ControllerService controllerService;
|
||||
private final InviteLinkRepositoryService inviteLinkRepositoryService;
|
||||
@Autowired
|
||||
Gruppen2Config gruppen2Config;
|
||||
private final Gruppen2Config gruppen2Config;
|
||||
|
||||
public Gruppen2Controller(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService) {
|
||||
public Gruppen2Controller(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService, Gruppen2Config gruppen2Config) {
|
||||
this.keyCloakService = keyCloakService;
|
||||
this.groupService = groupService;
|
||||
this.userService = userService;
|
||||
this.controllerService = controllerService;
|
||||
this.inviteLinkRepositoryService = inviteLinkRepositoryService;
|
||||
this.gruppen2Config = gruppen2Config;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,6 +258,10 @@ public class Gruppen2Controller {
|
||||
public String pDeleteGroup(KeycloakAuthenticationToken token, @RequestParam("group_id") Long groupId){
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
Group group = userService.getGroupById(groupId);
|
||||
if(group.getRoles().get(user.getId()) != Role.ADMIN ){
|
||||
return "error";
|
||||
}
|
||||
controllerService.deleteGroupEvent(user.getId(), groupId);
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
</form>
|
||||
<form action="/gruppen2/deleteGroup" method="post">
|
||||
<button class="btn btn-danger" style="border-style: none; margin: 5px"
|
||||
th:name="group_id" th:value="${group.getId()}"
|
||||
th:name="group_id" th:value="${group.getId()}" th:if="${group.getRoles().get(user.getId()) == admin}"
|
||||
type="submit">Gruppe löschen
|
||||
</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user