You are not logged in.
Pages: 1
Hi All,
I'm trying to connect my FMX app created with Delphi XE7 to my Server mormot but i don't handle the basic authentification process...
The final goal is to store some values from the client in the session like the current version of the app to retrieve it when the client call a method (i think i need to define the service with sicPerSession to get the data from the CurrentServiceContext).
When i do SetUser on the client i have an error server-side : "Invalid TAuthSession.Create(TSQLREstRoutingRest, TSQLAuthUser)".
I tried with TSQLRestServerAuthenticationNone and Server := TSQLRestServerFullMemory.Create(Model, false); to check if i can connect without control access but i have the same message.
Any idea about what i'm doing wrong ?
I have the 1.18 version of the framework.
Thanks in advance.
PS : I checked the samples, but i didn't found a fmx client (crossplatform units) which call SetUser to login to a server.
here some code about :
// SERVER SIDE
procedure TMainDM.CreateUsers;
var
  lGrp:TSQLAuthGroup;
  lUser:TSQLAuthUSer;
begin
  lGrp := TSQLAuthGroup.Create;
  try
    if Server.Retrieve('Ident=User', lGrp) then
    begin
      lUser := TSQLAuthUser.Create;
      try
        lUser.LogonName := 'TEST';
        lUser.DisplayName := 'TEST';
        lUser.GroupRights := lGrp;
        lUser.PasswordPlain := '';
        lUser.Data := '';
        Server.AddOrUpdate(lUser, true);
      finally
        FreeAndNil(lUser);
      end;
    end;
  finally
    FreeAndNIl(lGrp);
  end;
end;
procedure TMainDM.DataModuleCreate(Sender: TObject);
begin
  // initialize a TObjectList-based database engine
  Model := TSQLModel.Create([TSQLAuthGroup, TSQLAuthUser]);
  Server := TSQLRestServerFullMemory.Create(Model, true);
  Server.CreateMissingTables;
  Server.AuthenticationRegister(TSQLRestServerAuthenticationDefault);
  CreateUsers;
  // launch the HTTP server
  HTTPServer := TSQLHttpServer.Create('7277',[Server],'+',useHttpSocket);
  HTTPServer.AccessControlAllowOrigin := '*'; // for AJAX requests to work
end;
// CLIENT SIDE
const
_SERVERIP = 'localhost';
_SERVERPORT = 7277;
procedure TForm1.ButtonCoClick(Sender: TObject);
begin
  if not FCLient.Connect then
  begin
    log.d('Can''t connect !!!');
    exit;
  end;
  if FClient.ServerTimeStamp = 0 then
  begin
    log.d('Server incorrect !!!');
    exit;
  end;
  if not FCLient.SetUser(TSQLRestServerAuthenticationDefault, 'TEST', '') then
  begin
    log.d('Can''t login !!!');
    exit;
  end;
  showmessage('CONNECTED !');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  FModel := TSQLModel.Create([]);
  FClient := TSQLRestClientHTTP.Create(_SERVERIP, _SERVERPORT, FModel);
end;Last edited by ep (2017-02-08 17:15:50)
Offline
up
Offline
today is all about mobile` , synopse really need a full functional Fmx Client . like login auth, encript, zip/unzip soa restcall etc
Offline
hello,have you solved it ?
up
Offline
Pages: 1