Unable to UserAuthenticate - WeOnlyDo Discussion board

Unable to UserAuthenticate (General questions)

by DaveFromClenney, Friday, May 01, 2009, 04:52 (5684 days ago)

I recently purchased this control and am thoroughly impressed with it, but at this moment I can't so a simple username / password. Even if I hard code the username and password into the code, It returns with not authorized page. I'm using the example that includes scripting that came with the control as a test bed and if anyone could point me in the right direction as to what I'm doing wrong, I would greatly appreciate it.

[code]
Option Explicit
Dim WithEvents Web1 As wodWebServerCom

Private Sub Form_Load()
Set Web1 = New wodWebServerCom
Web1.Authentication = AuthRequired
Web1.AuthenticationType = AuthBasic
Web1.Port = 80
Web1.Start

End Sub

Private Sub Web1_RequestHeaders(ByVal User As WODWEBSERVERCOMLib.IWebUser)
Dim a As String
Debug.Print Received headers from user & User.RemoteIP

' prepare outgoing file
User.Response.FileName = App.Path & index.htm
User.Response.StatusCode = OK

' set up scripting
User.Response.ScriptBegin = <
User.Response.ScriptEnd = >

' now when page is opened, RunScript event will fire

End Sub

Private Sub Web1_RunScript(ByVal User As WODWEBSERVERCOMLib.IWebUser, ByVal ScriptData As String, ResponseData As String)

If ScriptData = HOSTNAME Then ResponseData = User.RemoteIP
If ScriptData = DATE Then ResponseData = Now

End Sub

Private Sub Web1_StateChange(ByVal User As WODWEBSERVERCOMLib.IWebUser, ByVal OldState As WODWEBSERVERCOMLib.StatesEnum)
Debug.Print State changed to & User.StateText
End Sub

Private Sub Web1_UserAuthenticate(ByVal User As WODWEBSERVERCOMLib.IWebUser, ByVal AuthType As WODWEBSERVERCOMLib.WebAuthenticationTypes, Action As WODWEBSERVERCOMLib.WebActions)
If User.Login = test And User.Password = test Then
Action = Allow
Else
Action = Deny
End If

End Sub

Private Sub Web1_UserConnected(ByVal User As WODWEBSERVERCOMLib.IWebUser, Action As WODWEBSERVERCOMLib.WebActions)
Debug.Print User from & User.RemoteIP & connected
End Sub

Private Sub Web1_UserDisconnected(ByVal User As WODWEBSERVERCOMLib.IWebUser)
Debug.Print User from & User.RemoteIP & disconnected
End Sub

[/code]

Re: Unable to UserAuthenticate

by wodDamir, Saturday, May 02, 2009, 00:04 (5684 days ago) @ DaveFromClenney

Hi Dave,

Sorry for responding slower, it's holiday here.

If I'm correct when you access your page, you do get login form shown?

However, when you try to login, RequestHeaders event is triggered twice (normal, since user is first rejected since no username/password is provided) which actually re-creates your index.htm file with not authorized page. You can test that by logging in (you get unauthorized), then replace your index.htm with the original and reload the page.

In order to solve this, simply move the RequestHeaders event into RequestDone.

Hope this helps.

Regards,
Damba

Re: Unable to UserAuthenticate

by DaveFromClenney1, Saturday, May 02, 2009, 02:18 (5684 days ago) @ wodDamir

Hi Dave,

Sorry for responding slower, it's holiday here.

If I'm correct when you access your page, you do get login form shown?

However, when you try to login, RequestHeaders event is triggered twice (normal, since user is first rejected since no username/password is provided) which actually re-creates your index.htm file with not authorized page. You can test that by logging in (you get unauthorized), then replace your index.htm with the original and reload the page.

In order to solve this, simply move the RequestHeaders event into RequestDone.

Hope this helps.

Regards,
Damba

Damba,

Thank you for the reply. After a night of sleep and a pot of coffee I was able to walk thru the code and find exactly what you described. After I moved my events to the RequestDone sub everything fell right into place. Again, thank you for your reply and for confirming what I believed to be true. I'm sure I will be back with more questions later. [:happy:] (btw, this is DaveFromClenney but I can't remember what password I used for this account, it was a late night indeed.
[:wink:] )