Skip to content

Commit

Permalink
Redirect to login after logout in mijn app
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Feb 26, 2024
1 parent fd39be0 commit e98cc78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion myconext-gui/src/routes/Landing.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
});
const loginAgain = () => {
window.location.href = `${$config.idpBaseUrl}/doLogin`;
window.location.href = `${$config.idpBaseUrl}/doLogin?register=false`;
}
</script>
Expand Down
13 changes: 8 additions & 5 deletions myconext-server/src/main/java/myconext/api/LoginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public Map<String, Object> config() {
public void register(@RequestParam(value = "lang", required = false, defaultValue = "en") String lang,
@RequestParam(value = "location", required = false) String location,
HttpServletResponse response) throws IOException {
doRedirect(lang, location, response);
doRedirect(lang, location, response, true);
}

@GetMapping("/register/{enrollmentVerificationKey}")
Expand Down Expand Up @@ -125,13 +125,16 @@ public void register(@PathVariable("enrollmentVerificationKey") String enrollmen
@GetMapping("/doLogin")
public void doLogin(@RequestParam(value = "lang", required = false, defaultValue = "en") String lang,
@RequestParam(value = "location", required = false) String location,
@RequestParam(value = "register", required = false, defaultValue = "true") String register,
HttpServletResponse response) throws IOException {
doRedirect(lang, location, response);
doRedirect(lang, location, response, Boolean.valueOf(register));
}

private void doRedirect(String lang, String location, HttpServletResponse response) throws IOException {
String cookieValue = String.format("%s=true; Max-Age=%s; SameSite=None%s", REGISTER_MODUS_COOKIE_NAME, 60 * 10, secureCookie ? "; Secure" : "");
response.setHeader("Set-Cookie", cookieValue);
private void doRedirect(String lang, String location, HttpServletResponse response, boolean register) throws IOException {
if (register) {
String cookieValue = String.format("%s=true; Max-Age=%s; SameSite=None%s", REGISTER_MODUS_COOKIE_NAME, 60 * 10, secureCookie ? "; Secure" : "");
response.setHeader("Set-Cookie", cookieValue);
}
String redirectLocation = StringUtils.hasText(location) ? location : this.config.get("eduIDLoginUrl") + "&lang=" + lang;
response.sendRedirect(redirectLocation);
}
Expand Down

0 comments on commit e98cc78

Please sign in to comment.