Guest User

Untitled

a guest
Dec 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. @Autowired
  2. private AuthHandler authHandler;
  3.  
  4. @GetMapping("/userLogin")
  5. @ResponseBody
  6. public String userLogin() {
  7. if(authHandler.isLogged()) {
  8. return "User is already logged in";
  9. } else {
  10. authHandler.setLogged(true);
  11. return "User has been logged in";
  12. }
  13. }
  14.  
  15. @GetMapping("/userLogOut")
  16. @ResponseBody
  17. public String userLogOut() {
  18. if(authHandler.isLogged()) {
  19. authHandler.setLogged(false);
  20. return "You have been logged out";
  21. } else {
  22. return "You are not logged in, we can't logg you out";
  23. }
  24. }
  25.  
  26. @GetMapping("/userCheckAuth")
  27. @ResponseBody
  28. public String userCheckAuth() {
  29. if(authHandler.isLogged()) {
  30. return "You have access to the page";
  31. } else {
  32. return "You don't have access to this site";
  33. }
  34. }
Add Comment
Please, Sign In to add comment