layout cleanup

This commit is contained in:
Jottyfan
2022-11-14 15:16:10 +01:00
parent 55ff76c29b
commit abeba4935c
18 changed files with 795 additions and 722 deletions

View File

@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import de.jottyfan.camporganizer.module.registration.KeycloakRepository;
/**
*
* @author jotty
@@ -24,6 +26,9 @@ public class IndexController extends CommonController {
@Autowired
private HttpServletRequest request;
@Autowired
private KeycloakRepository keycloak;
@Autowired
private IndexService service;
@@ -39,6 +44,7 @@ public class IndexController extends CommonController {
super.setupSession(model, request);
model.addAttribute("mybookings", service.getBookingsOf(super.getCurrentUser(request)));
model.addAttribute("bookingBean", new BookingBean());
model.addAttribute("keycloakProfileUrl", keycloak.getUserClientUrl());
return "/dashboard";
}

View File

@@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
/**
*
*
* @author henkej
*
*/
@@ -16,23 +16,35 @@ public class KeycloakRepository {
@Value("${keycloak.resource:biblecamp}")
private String keycloakClientId;
@Value("${keycloak.auth-server-url}")
private String keycloakUrl;
@Value("${keycloak.realm:ow}")
private String keycloakRealm;
/**
* get the url of the user client
*
* @return the url of the user client
*/
public String getUserClientUrl() {
String url = keycloakUrl == null ? null
: (keycloakUrl.substring(0, keycloakUrl.length() - (keycloakUrl.endsWith("/") ? 1 : 0)));
return String.format("%s/realms/%s/account/", url, keycloakRealm);
}
/**
* register the login in keycloak
*
*
* @param login
* @param password
*/
public void register(String login, String password) {
// TODO: check for trailing and leading /
String registrationUrl = String.format("%s/admin/realms/%s/users", keycloakUrl, keycloakRealm);
// see https://www.keycloak.org/docs-api/17.0/rest-api/index.html#_users_resource
// see
// https://www.keycloak.org/docs-api/17.0/rest-api/index.html#_users_resource
// https://canada1.discourse-cdn.com/free1/uploads/keycloak/original/2X/3/379bbfe8857de117771149174a96e4216ebe9c76.png
// TODO Auto-generated method stub
LOGGER.error("not yet implemented registration of user {} in keycloak", login);