This commit is contained in:
2026-07-27 21:42:45 +05:30
parent cd11b389e5
commit f264f90f3b
70 changed files with 46 additions and 687 deletions

View File

@@ -1,46 +1,45 @@
package matrix.nimble.controller;
package matrix.nimble.controller;
import java.util.Map;
import matrix.nimble.cloud.identity.CloudAuthenticationException;
import matrix.nimble.cloud.identity.CloudAuthenticationGateway;
import matrix.nimble.model.Login;
import matrix.nimble.model.Session;
//servlet libraries
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
//spring libraries
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
@Controller
@SessionAttributes("Sessvals")
//servlet libraries
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
//spring libraries
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
@Controller
@SessionAttributes("Sessvals")
public class SessionController {
private final CloudAuthenticationGateway cloudAuthenticationGateway;
public SessionController(CloudAuthenticationGateway cloudAuthenticationGateway) {
this.cloudAuthenticationGateway = cloudAuthenticationGateway;
}
@RequestMapping(value="login",method=RequestMethod.POST )
public String LoginPage(ModelMap model,@RequestHeader Map<String, String> headers)
{
model.addAttribute("login", new Login());
String host = headers.get("host").toString();
if(!host.contains("192.168.10.205:8585") &&
!host.contains("192.168.10.250:8585") &&
!host.startsWith("localhost:") && !host.startsWith("127.0.0.1:")) {
return "error";
}
return "login";
}
@RequestMapping(value="logout",method=RequestMethod.POST )
// @RequestMapping(value="login",method=RequestMethod.POST )
// public String LoginPage(ModelMap model,@RequestHeader Map<String, String> headers)
// {
// model.addAttribute("login", new Login());
// String host = headers.get("host").toString();
// if(!host.contains("192.168.10.205:8585") &&
// !host.contains("192.168.10.250:8585") &&
// !host.startsWith("localhost:") && !host.startsWith("127.0.0.1:")) {
// return "error";
// }
// return "login";
// }
@RequestMapping(value="logout",method=RequestMethod.POST )
public String LogoutPage(HttpServletRequest request, ModelMap model,@ModelAttribute(value="Sessvals") Session Sessvals)
{
HttpSession session = request.getSession(false);
@@ -69,17 +68,17 @@ public class SessionController {
return "login";
}
}
@RequestMapping(value="dashboard",method=RequestMethod.POST )
public String Dashboard(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals)
{
if(Sessvals == null)
{
return "redirect:/logout";
}
else
{
model.addAttribute("Sessvals",Sessvals);
return "dashboard";
}
}
}
@RequestMapping(value="dashboard",method=RequestMethod.POST )
public String Dashboard(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals)
{
if(Sessvals == null)
{
return "redirect:/logout";
}
else
{
model.addAttribute("Sessvals",Sessvals);
return "dashboard";
}
}
}