#1 2014-05-04 03:06:37

mingda
Member
Registered: 2013-01-04
Posts: 121

after success login, can also return user's DisplayName

procedure TSQLRestServerAuthentication.SessionCreate(Ctxt: TSQLRestServerURIContext;
  var User: TSQLAuthUser);
var Session: TAuthSession;
begin
  if User<>nil then
  try
    // now client is authenticated -> create a session
    fServer.SessionCreate(User,Ctxt,Session);
    if Session<>nil then
      Ctxt.Returns(['result',Session.fPrivateSalt,'logonname',Session.User.LogonName]);
  finally
    User.Free;
  end;
end;

a little request, after success login, can also return user's DisplayName in return JSON object, thanks!

Offline

#2 2014-05-04 14:25:46

warleyalex
Member
From: Sete Lagoas-MG, Brasil
Registered: 2013-01-20
Posts: 250

Re: after success login, can also return user's DisplayName

After authentication, you need to get session ID and use SessionGetUser function to get logonName.

Ctxt.Returns(['SessionID',Ctxt.Session,'UserID',Ctxt.SessionUser,'GroupRightsID',Ctxt.SessionGroup,'UserName',SessionGetUser(Ctxt.Session).LogonName]);

{"SessionID":5385784,"UserID":3,"GroupRightsID":3,"UserName":"User"}

Offline

#3 2014-05-05 13:55:08

mingda
Member
Registered: 2013-01-04
Posts: 121

Re: after success login, can also return user's DisplayName

I use a web front, when client call '/auth?UserName=XXX&Password=XX&ClientNonce=XXX' to login, server will return a json object with "logonname" and private key, since logonname is just equal UserName, I have already know it, i need the user's DisplayName, then I need make a service interface to get this info, if when call /auth?, have return the DisplayName, then will don't need make this interface, hope it clear, thanks!

Offline

#4 2014-05-05 17:15:17

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

Re: after success login, can also return user's DisplayName

You can create your own class, and override .SessionCreate() method to return the expected content.

Offline

Board footer

Powered by FluxBB