AuthorizationManager.Logout(const ALoginToken:string) doesn’t fill the ctx!

Home Forums kbmMW AuthorizationManager.Logout(const ALoginToken:string) doesn’t fill the ctx!

Viewing 6 reply threads
  • Author
    Posts
    • #56280
      Babis Michael
      Participant

      Hello,

      AuthorizationManager.Logout(const ALoginToken:string) doesn’t provide the TkbmMWAuthorizationContext information as
      TkbmMWAuthorizationManager.Logout(const AActor:TkbmMWAuthorizationActor) does needed by the Logout2 event
      of TkbmMWAuthorizationManager!

      Copied and modified a bit the code from TkbmMWAuthorizationManager.Logout(const AActor:TkbmMWAuthorizationActor)
      and it works!

      procedure TkbmMWAuthorizationManager.Logout(const ALoginToken:string);
      var
      ctx:TkbmMWAuthorizationContext;
      l:TkbmMWAuthorizationLogin;
      begin
      ctx:=TkbmMWAuthorizationContext.Create;
      try
      FLock.BeginWrite;
      try
      l:=FLogins.Get(ALoginToken);
      ctx.Token:=l.Token;
      ctx.ActorName:=l.Actor.Name;
      ctx.Role:=l.Role;
      ctx.Login:=l;
      DoOnLogout(ctx);
      ctx.TraceMessage:=’Logout: LoginToken=’+ctx.Token;
      DoOnTrace(ctx);
      FLogins.Delete(l.Actor);
      finally
      FLock.EndWrite;
      end;
      finally
      ctx.Free;
      end;
      end;

      Thank you

    • #56281
      Babis Michael
      Participant

      btw, GarbageCollect calls the TkbmMWAuthorizationManager.Logout(const ALoginToken:string);

    • #56343
      kimbomadsen
      Keymaster

      Hi

      There will be an additional set of events which will include the context.
      The first context less event will be called first, then the event with context.

      /Kim

      • #56355
        Babis Michael
        Participant

        Hello!
        No it doesn’t not! It’s empty and never fills!
        As you can see in the code it only assigns the “Token” compared to Logout(const AActor:TkbmMWAuthorizationActor);

        procedure TkbmMWAuthorizationManager.Logout(const ALoginToken:string);

        ctx:=TkbmMWAuthorizationContext.Create;
        try
        ctx.Token:=ALoginToken; //Only this!!!
        FLock.BeginWrite;
        try
        DoOnLogout(ctx);
        ….

        procedure TkbmMWAuthorizationManager.Logout(const AActor:TkbmMWAuthorizationActor);
        ….
        ctx.Token:=l.Token;
        ctx.ActorName:=AActor.Name;
        ctx.Role:=l.Role;
        ctx.Login:=l;
        DoOnLogout(ctx);
        ….

        The ctx information is needed for login2 and logout2 and trace2 of AuthorizationManager!
        So in case that GarbageCollection Logout out the user i use the CTX to retrieve his informations. (eg the Actorname).

        Thank you

    • #56410
      Babis Michael
      Participant

      UP

    • #56431
      Babis Michael
      Participant

      New code to avoid AV:

      ctx.Token:=ALoginToken;
      FLock.BeginWrite;
      try
      l:=FLogins.Get(ALoginToken); // New

      if Assigned(l) then // New
      begin
      ctx.Token:=l.Token;
      ctx.ActorName:=l.Actor.Name;
      ctx.Role:=l.Role;
      ctx.Login:=l;
      end;

      DoOnLogout(ctx);
      ctx.TraceMessage:=’Logout: LoginToken=’+ctx.Token;
      DoOnTrace(ctx);

      FLogins.Delete(l.Actor);
      finally
      FLock.EndWrite;
      end;

    • #56722
      Babis Michael
      Participant

      Kim, this isn’t fixed in 5.20! (you forgot it)

    • #56735
      kimbomadsen
      Keymaster

      Hi,

      Will fix in fix release.

      /Kim

Viewing 6 reply threads
  • You must be logged in to reply to this topic.