link is now displayed correctly but still issus with localhost and keykloak
Co-authored-by: Max Oerter <33197299+mahgs@users.noreply.github.com>
This commit is contained in:
@ -19,6 +19,7 @@ import mops.gruppen2.service.KeyCloakService;
|
||||
import mops.gruppen2.service.UserService;
|
||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -31,13 +32,18 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import java.io.CharConversionException;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Controller
|
||||
@SessionScope
|
||||
@RequestMapping("/gruppen2")
|
||||
public class Gruppen2Controller {
|
||||
@Autowired
|
||||
Environment environment;
|
||||
|
||||
private final KeyCloakService keyCloakService;
|
||||
private final GroupService groupService;
|
||||
@ -45,6 +51,7 @@ public class Gruppen2Controller {
|
||||
private final ControllerService controllerService;
|
||||
private final InviteLinkRepositoryService inviteLinkRepositoryService;
|
||||
private final Gruppen2Config gruppen2Config;
|
||||
private final Logger logger;
|
||||
|
||||
public Gruppen2Controller(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService, Gruppen2Config gruppen2Config) {
|
||||
this.keyCloakService = keyCloakService;
|
||||
@ -53,6 +60,7 @@ public class Gruppen2Controller {
|
||||
this.controllerService = controllerService;
|
||||
this.inviteLinkRepositoryService = inviteLinkRepositoryService;
|
||||
this.gruppen2Config = gruppen2Config;
|
||||
this.logger = Logger.getLogger("gruppen2ControllerLogger");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,6 +203,24 @@ public class Gruppen2Controller {
|
||||
String link = inviteLinkRepositoryService.findlinkByGroupId(group.getId());
|
||||
model.addAttribute("link", link);
|
||||
|
||||
String port ="";
|
||||
String serverAd="";
|
||||
try {
|
||||
port = environment.getProperty("server.port");
|
||||
serverAd= InetAddress.getLoopbackAddress().getHostAddress();
|
||||
} catch (Exception e) {
|
||||
logger.warning("Could not find server-address");
|
||||
}
|
||||
if (port.isEmpty()){
|
||||
logger.warning("Serverport missing in application.properties");
|
||||
}
|
||||
|
||||
// hässlicher hardcode
|
||||
serverAd = "localhost";
|
||||
|
||||
String serverAddresse = serverAd + ":" + port;
|
||||
model.addAttribute("serverAddress", serverAddresse);
|
||||
|
||||
return "detailsMember";
|
||||
}
|
||||
|
||||
|
@ -18,3 +18,4 @@ keycloak.use-resource-role-mappings=true
|
||||
keycloak.autodetect-bearer-only=true
|
||||
keycloak.confidential-port=443
|
||||
server.error.include-stacktrace=always
|
||||
server.port=8080
|
||||
|
@ -42,11 +42,13 @@
|
||||
th:if='${group.getType() == group.getType().LECTURE}'>Veranstaltung</span>
|
||||
<span class="badge badge-pill badge-info" style="background: mediumorchid"
|
||||
th:text="${parent.getTitle()}">Parent</span>
|
||||
|
||||
Click <a th:href="@{'/gruppen2/acceptinvite/' + ${link}}">view</a> to go to yahoo.
|
||||
<div class="input-group mb-3" style="margin-top: 10px" th:if="${group.getVisibility() == group.getVisibility().PRIVATE}">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-default" style="background: #52a1eb">Einladungslink:</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" th:value="${link}"
|
||||
<input type="text" class="form-control" th:value="|${serverAddress}/gruppen2/acceptinvite/${link}|"
|
||||
aria-label="Recipient's username" aria-describedby="basic-addon2" id="groupLink" style="background: white" readonly>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-secondary" type="button" onclick="copyLink()">Link kopieren</button>
|
||||
@ -113,7 +115,6 @@
|
||||
<script>
|
||||
function copyLink() {
|
||||
var copyText = document.getElementById("groupLink");
|
||||
console.log("sads");
|
||||
|
||||
copyText.select();
|
||||
copyText.setSelectionRange(0, 99999);
|
||||
|
Reference in New Issue
Block a user