Checking in whether SphinxWebLogin.AuthResult is assigned

I want to test whether my TSphinxWebLogin is already logged in, which I do by:

procedure TForm1.WebButton1Click(Sender: TObject);
begin
  if not (Assigned (SphinxWebLogin1.AuthResult)) or not((SphinxWebLogin1.IsLoggedIn)) then SphinxWebLogin1.Login
  else XDataWebDataSet1.Load;
end;

But this results in:

Uncaught TypeError: Cannot read properties of null (reading 'AuthResult') | TypeError: Cannot read properties of null (reading 'AuthResult') at rtl.module.rtl.createClass.AuthResult

I noticed that this is due to (in Sphinx.WebLogin):

function TSphinxWebLogin.AuthResult: TAuthResult;
begin
Result := FStorage.AuthResult;
end; 

it seems FStorage is already null

Then by making this change in Sphinx.WebLogin:

function TSphinxWebLogin.AuthResult: TAuthResult;
begin
  if FStorage = nil then result := nil
  else
  Result := FStorage.AuthResult;
end;

it works.

OR should I only check on IsLoggedIn ?

Thanks

You can use IsLoggedIn, yes. But we will improve that check in AuthResult, thanks for pointing out.