#1 2025-11-15 05:39:32

larand54
Member
Registered: 2018-12-25
Posts: 113

Error in tbo:s example

I am trying to help a friend using mORMot2 by giving him some examples but have hard to make some of them to work.

I thought I could use some of the examples in the "ex"-folder but failed to compile some of them.

Here I show the problems with tbo:s example:
04-HttpServer-InterfaceServices
This one I could make to work though:
TestRestClient.dpr

unit frm_Main;
    if FDocumentService.Client.SetUser(pmcUserName, TAuthUser.ComputeHashedPassword(pmcPassword), True) then             //  - Does not compile

I added pmcUserName:

    if FDocumentService.Client.SetUser(pmcUserName, TAuthUser.ComputeHashedPassword(pmcUserName,pmcPassword), True) then // - Compile

   
Have not found a solution for this:
TestRestServer.dpr
unit u_ServiceServer;

  if IsValidJson(json)
    and (DynArrayLoadJson(customers, json, TypeInfo(TCustomerItemArray)) <> Nil)// - Does not compile - "Incompatible types"

So I need some help to fix this code and wonder how this could happend?
Have mormot2 later updates caused this or have I missed something?


Delphi-11, WIN10

Offline

#2 2025-11-15 10:18:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,276
Website

Re: Error in tbo:s example

ComputeHashedPassword() signature did change because of indeed some new features.
The proper way is just to call SetUser(pmcUserName, pmcPassword), not this method which is documented as "internal".
I don't know why Thomas did use this syntax. I guess he was confused by our code. Last months, I tried to make the documentation clearer. Hope it is now.

DynArrayLoadJson() usage has been changed because the previous method returning a pointer was really confusing. Now it just return a boolean.
There is no point of calling IsValidJson() first, I guess.

All those are third-party demos which I did not write, not fully checked for best usecases, and we were never supposed to maintain them.
They don't even compile with XE8.

I have tried to fix the compilation:
https://github.com/synopse/mORMot2/commit/50f2ce5bd
But not tested them - so any input is welcome: pull request are always a good way to go. big_smile

Offline

Board footer

Powered by FluxBB