Hi
I have setting a filter : srvr.AddFilter("*", "MemberFilter",False) to showing login form. In filter, I get error as following :
req.FullRequestURI -->> http://127.0.0.1:8001/param/mon/index.html -->> Redirect to /login/ is OK
req.FullRequestURI -->> http://127.0.0.1:8001/param/day/ws -->> Redirect to /login/ is NG
I have setting a filter : srvr.AddFilter("*", "MemberFilter",False) to showing login form. In filter, I get error as following :
req.FullRequestURI -->> http://127.0.0.1:8001/param/mon/index.html -->> Redirect to /login/ is OK
req.FullRequestURI -->> http://127.0.0.1:8001/param/day/ws -->> Redirect to /login/ is NG
B4X:
Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean
Log("filter : " & req.FullRequestURI)
Dim fp1 As Boolean=req.FullRequestURI.IndexOf("/param")>=0
Dim fp2 As Boolean=req.FullRequestURI.IndexOf("logoutHelper")>=0
Dim fp3 As Boolean=req.FullRequestURI.IndexOf("/ws")>=0
If fp1 And Not(fp2) Then
Dim registered As Boolean=req.GetSession.GetAttribute2("registered",False)
Dim username As String=req.GetSession.GetAttribute2("name", "")
Log("registered:"&b4jlib.IIF(registered,"true","false")&" , name:"&username)
If registered=True Then
'check that no more than 30 minutes passed since last activity
If req.GetSession.LastAccessedTime + DateTime.TicksPerMinute * 30 > DateTime.Now Then
Return True 'allow request to continue
End If
Log("user have login")
End If
resp.SendRedirect("/login/") <<<--- problem in here
Return False
Log("Redirect to /login/")
else If fp2 Then
resp.ContentType = "application/json"
Dim jg As JSONGenerator
Dim responeMap As Map
responeMap.Initialize
responeMap.Put("success",True)
responeMap.Put("goto","/monitor/index.html")
responeMap.Put("errorMessage", "")
jg.Initialize(responeMap)
resp.Write(jg.ToString)
req.GetSession.RemoveAttribute("registered")
req.GetSession.RemoveAttribute("name")
Log("=== logout ===")
Return False
Else
Return True
End If
End Sub