Skip to content

Instantly share code, notes, and snippets.

@odedia
Last active November 20, 2017 13:31
Show Gist options
  • Select an option

  • Save odedia/94f4d97d2ca22757d4af34be01479b3e to your computer and use it in GitHub Desktop.

Select an option

Save odedia/94f4d97d2ca22757d4af34be01479b3e to your computer and use it in GitHub Desktop.
package com.odedia.springsession.rest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class LoginManagementResource {
@GetMapping("/login")
public String login(HttpServletRequest request, HttpSession session) {
if (!session.isNew()) {
session.invalidate();
}
return "login";
}
@GetMapping("/logout")
public String logout() {
return "redirect:/login";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment