LoginController.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package es.uv.saic.web;
  2. import java.io.IOException;
  3. import java.util.List;
  4. import jakarta.servlet.http.HttpSession;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.security.core.Authentication;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.ui.Model;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.RequestParam;
  11. import es.uv.saic.domain.Noticia;
  12. import es.uv.saic.feign.NoticiaClient;
  13. @Controller
  14. public class LoginController {
  15. @Autowired
  16. private NoticiaClient nc;
  17. @Autowired
  18. private ProceduresController procedures;
  19. @GetMapping("/login")
  20. public String get(Model model, Authentication auth, HttpSession session, @RequestParam(required = false) String error) throws IOException {
  21. if(auth != null) {
  22. return procedures.getActiveInstances(model, auth, session, null);
  23. }
  24. else {
  25. if(error != null) {
  26. if(error.equals("expired")) {
  27. model.addAttribute("expired", true);
  28. }
  29. else {
  30. model.addAttribute("error", true);
  31. }
  32. }
  33. model.addAttribute("notices", null);
  34. List<Noticia> l = this.nc.findVisibles();
  35. if(l != null) {
  36. if(!l.isEmpty()) {
  37. model.addAttribute("notices", l);
  38. }
  39. }
  40. return "login";
  41. }
  42. }
  43. }