Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread HTTP Post Password and Username
Fri, Mar 16 2018 2:08 PMPermanent Link

KimHJ

Comca Systems, Inc

When I create a module in EWB  I get :

if AuthenticateUser(Request) then
     begin
           case Request.RequestMethod of
        rmGet:
        rmHead:
        rmPost:
    end;

And if I add OnAuthenticateUser I get:

procedure TEWBModule1.EWBModuleAuthenticateUser(const RequestUserName,
 RequestPassword: string; var Authenticated: Boolean);
begin
    if RequestUserName = 'myname' then
     begin
          if RequestPassword = 'mypassword' then
             Authenticated := True;
     end
  else
     Authenticated := False;
end;

The OnAuthenticateUser works fine with GET but not with POST.

PhoneReq:= TServerRequest.Create(nil);
    with PhoneReq do
         begin   
                 Try
                 Method:=rmPost;
                 URL:='/modules/mymodule';  
                 RequestHeaders.Clear;
                 RequestHeaders.Values['Content-Type']:='text/plain';
                 RequestContent.Clear;
                 username:='myname';
                 password:='mypassword';
                 RequestContent.Values['storeid']:=CSStoreId;                
                 RequestContent.Values['phone']:=Phone;
                 OnComplete := CheckForPhoneComplete;
                 try
                     Execute;
                 except
                 end;
                 finally
                      Free;
                 end;
         end;


PhoneReq:= TServerRequest.Create(nil);
    with PhoneReq do
         begin   
                 Try
                 Method:=rmGet;
                 URL:='/modules/mymodule';  
                 RequestHeaders.Clear;
                 RequestHeaders.Values['Content-Type']:='text/plain';
                 RequestContent.Clear;
                 RequestContent.Values['username']:='myname';
                 RequestContent.Values['password']:='mypassword';
                 RequestContent.Values['storeid']:=CSStoreId;                
                 RequestContent.Values['phone']:=Phone;
                 OnComplete := CheckForPhoneComplete;
                 try
                     Execute;
                 except
                 end;
                 finally
                      Free;
                 end;
         end

What do I do wrong?
Thanks,
Kim
Fri, Mar 16 2018 8:08 PMPermanent Link

KimHJ

Comca Systems, Inc

I found it.
I have to use the X-EWBUser and the X-EWBPassword in the RequestHeader.

Kim
Image