Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 13 total
Thread OnLoadError message
Tue, Oct 13 2015 6:32 AMPermanent Link

Uli Becker

Using a module, I want to check user and password:

if DatabaseAdapter.AuthenticateUser(Request) = false then
begin
   Request.SendError(401, 'Unauthorized user');
   exit;
end;

In the OnLoadError of a dataset I use this code:

   showmessage(ErrorMsg);

The ErrorMsg is: "Dataset load response error (Cannot connect to server)"

How can I pass a detailed error message to the EWB client?

Thanks Uli
Tue, Oct 13 2015 9:01 AMPermanent Link

Raul

Team Elevate Team Elevate

On 10/13/2015 6:32 AM, Uli Becker wrote:
> In the OnLoadError of a dataset I use this code:
>
>     showmessage(ErrorMsg);
>
> The ErrorMsg is: "Dataset load response error (Cannot connect to server)"
>
> How can I pass a detailed error message to the EWB client?

This error would indicate app was unable to connect to your server so
how would you expect error message to be available ?

Looking at the TDatabase.RequestComplete handler the server request is
passed thru in the error message Except if it's blank or response code
is 0 (HTTP_NONE) - this is actually what you're seeing.

Otherwise you would get the error message back with either "Error
converting .." error or "Database commit response error .." and that
should include your server response as well.

However for auth you might be better off using TServerRequest directly
as then you can properly parse any response codes and data.

Raul
Tue, Oct 13 2015 9:17 AMPermanent Link

Uli Becker

Raul,

> This error would indicate app was unable to connect to your server so
> how would you expect error message to be available ?

But the app *did* connect to my server. After checking username and
password 401 is sent back to the client.

Uli
Tue, Oct 13 2015 9:22 AMPermanent Link

Raul

Team Elevate Team Elevate

On 10/13/2015 9:17 AM, Uli Becker wrote:
> But the app *did* connect to my server. After checking username and
> password 401 is sent back to the client.

Then you might need to trace this further and see if TServerRequest does
not pass result back then to TDatabase side of things.

Looking at the EWB framework I'm only seeing "ERR_DATA_CONNECT=Cannot
connect to server" error thrown in TDatabase.RequestComplete and only if
"Request.ResponseContent.Text=''" OR Request.StatusCode=HTTP_NONE.


Raul
Tue, Oct 13 2015 9:24 AMPermanent Link

Matthew Jones

Uli Becker wrote:

> How can I pass a detailed error message to the EWB client?

Isn't the answer in your question:

Request.SendError(401, 'Unauthorized user');

That message text can be got in the web client I'd expect, and you can
pass back whatever you want there.

--

Matthew Jones
Tue, Oct 13 2015 9:39 AMPermanent Link

Uli Becker

Matthew,

> Isn't the answer in your question:
>
> Request.SendError(401, 'Unauthorized user');
>
> That message text can be got in the web client I'd expect, and you can
> pass back whatever you want there.

No problem if I send a request, but how does that work using datasets?

IOW: I want to send username and password by setting database params.
When the auth fails, I'd like to display an error message 'Unauthorized
user". What is a clear way to do that?

Uli
Tue, Oct 13 2015 9:47 AMPermanent Link

Matthew Jones

Uli Becker wrote:

> IOW: I want to send username and password by setting database params.
> When the auth fails, I'd like to display an error message
> 'Unauthorized user". What is a clear way to do that?


Look for ERR_DATA_LOAD in the EWB source. That appears to be the source
of the text you are getting. The second part appears to be coming from
the server, so the 401 result must not be the end-effect, or there is
some other request happening. Have a look at the browser trace to see
if you can work out where your response is going.

--

Matthew Jones
Tue, Oct 13 2015 10:05 AMPermanent Link

Uli Becker

Mattew,

> Have a look at the browser trace to see
> if you can work out where your response is going.

I traced that:

Remote Address:127.0.0.1:80
Request
URL:http://localhost/memory/modules/EWBMemoryModul?method=rows&dataset=MEM_ShowScans&SubFoldersID=1289
Request Method:GET
Status Code:401 Error

HTTP/1.1 401 Error
Date: Tue, 13 Oct 2015 13:59:50 GMT
From:
Server: Elevate Web Builder Web Server
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
Content-Length: 0

So the status code is returned correctly (the custom text is skipped).
The question is: how can I get the error code when loading a dataset?

Uli
Tue, Oct 13 2015 10:17 AMPermanent Link

Raul

Team Elevate Team Elevate

On 10/13/2015 10:05 AM, Uli Becker wrote:
> HTTP/1.1 401 Error
> Date: Tue, 13 Oct 2015 13:59:50 GMT
> From:
> Server: Elevate Web Builder Web Server
> Connection: Keep-Alive
> Content-Type: text/html; charset=utf-8
> Content-Length: 0

This is the root of the problem - no response content text triggers the
error message you're seeing.

> So the status code is returned correctly (the custom text is skipped).
> The question is: how can I get the error code when loading a dataset?

You'd need to modify the framework source code to return the status code
at this point or wait and see if Tim can include it.

I'd seriously suggest though to not use dataset capability for
authentication - all what you're asking for is already available for
TServerRequest itself.

Raul
Tue, Oct 13 2015 10:32 AMPermanent Link

Uli Becker

Raul,

> I'd seriously suggest though to not use dataset capability for
> authentication - all what you're asking for is already available for
> TServerRequest itself.

OK, but how about the (EWB) database properties "Username" and
"Password", how about the TDatabaseAdapter's event "OnAuthenticateUser"
and method "AuthenticateUser"? Are these useless then?

Uli
Page 1 of 2Next Page »
Jump to Page:  1 2
Image