#1 2017-01-27 17:09:34

DavidRM
Member
Registered: 2016-12-19
Posts: 29

SessionUser.Data not Loading on SetUser

SetUser() is returning true, but the SessionUser.Data isn't there (it's empty). The Data column in the database is *not* empty.

procedure TJournalVolumeClient.LoginUser(const userLogin, userPassword: string);
var
  hashedPassword: RawUTF8;
  ...
  userData: Variant;
begin
    ...
    if FDatabase.SetUser(UnicodeStringToUTF8(userLogin), hashedPassword, true) then
    begin
      TDocVariant.New(userData);
      userData := VariantLoadJSON(FDatabase.SessionUser.Data);
     ...
end;

Am I missing a step?

-David

Offline

#2 2017-01-27 18:58:45

DavidRM
Member
Registered: 2016-12-19
Posts: 29

Re: SessionUser.Data not Loading on SetUser

OK, after digging around, I see the TSqlAuthUser 'Data' column isn't passed to the client. It's just on the server.

-David

Offline

#3 2017-01-31 12:56:00

StxLog
Member
From: France
Registered: 2015-09-14
Posts: 58

Re: SessionUser.Data not Loading on SetUser

And what is the best way to get the Data field client side? I have a TSQLUser class overriding TSQLAuthUser, and I need to have the Data field filled in the SessionUser. I've tried to do fClient.RetrieveBlobFields(fClient.SessionUser); as stated in the doc but it tell me I need TSQLAuthUser in the model, and if i do fClient.RetrieveBlob(TSQLUser, fClient.SessionUser.GetID, 'Data', fClient.SessionUser.Data); it tells me i'm not calling RetrieveBlob with the correct argument...
I can still do
  fClient.RetrieveBlob(TSQLUser, fClient.SessionUser.GetID, 'Data', aTmpData);
  fClient.SessionUser.Data := aTmpData;

but it seems weird

Am I missing something here?

Offline

#4 2017-01-31 13:23:42

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: SessionUser.Data not Loading on SetUser

In all cases, TSQLAuthUser should be in the model.

fClient.RetrieveBlobFields(fClient.SessionUser);

Is the way to go.

Offline

#5 2017-01-31 16:46:44

StxLog
Member
From: France
Registered: 2015-09-14
Posts: 58

Re: SessionUser.Data not Loading on SetUser

Well I have a TSQLAuthUser in my model trough my TSQLUser class:

TSQLUser = class(TSQLAuthUser)

So yes, if I directly use TSQLAuthUser as my user table, RetrieveBlobFields() work well, but if i'm using my own inherited class it doesn't work, as GetTableIndex doesn't find TSQLAuthUser.

It seemed to me that mORMot only allowed one TSQLAuthUser per model, so I would think GetTableIndex should return my inherited class. Am i misunderstanding something?

Offline

#6 2017-01-31 18:15:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: SessionUser.Data not Loading on SetUser

Please check https://synopse.info/fossil/info/02bb7882b5
It will ensure that any inherited TSQLAuthUser class (e.g. your TSQLUser) will be used to create the fClient.SessionUser field.

Offline

#7 2017-02-01 12:55:09

StxLog
Member
From: France
Registered: 2015-09-14
Posts: 58

Re: SessionUser.Data not Loading on SetUser

As usual, thanks for your fast reply and your help, i've updated the library and everything is working as expected ; )

Offline

#8 2019-04-05 12:25:01

hottabych
Member
Registered: 2019-04-05
Posts: 1

Re: SessionUser.Data not Loading on SetUser

I'm trying to get a SessionUser.Data field, but unsuccessfully.

  //user cTestUser was created with Data:='hello' and AuthGroup 'User'
  RESTClient.SetUser(cTestUser,cTestPass); //true
  RESTClient.RetrieveBlobFields(RESTClient.SessionUser); //there are False with 405 error (not allowed)
  RESTClient.SessionUser.Data; // is empty

What am I doing wrong? Thanks.

With "Supervisor" group all works as expected, but I need to get Data for any user.

Last edited by hottabych (2019-04-05 12:34:01)

Offline

#9 2019-04-08 06:51:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: SessionUser.Data not Loading on SetUser

This is as expected/designed in User rights.

Offline

#10 2019-04-10 18:03:40

guilhermeschenckel
Member
Registered: 2019-04-10
Posts: 5

Re: SessionUser.Data not Loading on SetUser

Is there a way to know how many requests are currently open in the TSQLRestServerFullMemory class?

Offline

Board footer

Powered by FluxBB