#1 2020-04-16 15:32:14

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Current user of the session on interface based service

Hello,

I have interface based service with enabled authentication.

I need to get current user of the server.

aRestServer.SessionGetUser(aSessionID: Cardinal): TSQLAuthUser;

looks like almost what I need.

The point is I can not find is how to get current sessionId.

Could you help me?

Thanks.

Offline

#2 2020-04-16 15:38:25

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Re: Current user of the session on interface based service

is this way correct?

var
  u: TSQLAuthUser;
begin
  u := aRestServer.SessionGetUser(ServiceContext.Request.Session);
end;

Offline

#3 2020-04-16 16:29:58

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Re: Current user of the session on interface based service

Don't forget that you will receive a copy of TSQLAuthUser, and you must destroy it in your method.

If you only need the user ID/Name, you can use:

 writeln('LogedUserID:', ServiceContext.Request.SessionUser);
 writeln('LogedUserName:', ServiceContext.Request.SessionUserName);

Offline

#4 2020-04-16 18:36:52

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Re: Current user of the session on interface based service

Thanks a lot! Works.

Offline

Board footer

Powered by FluxBB