Hello,
I watched the video of Holger Flick "Await to open new forms" and now I try to do the following:
On the mainform I'd like to check, if a cookie with a JWT is present. If not, the login form should be shown.
I tried this while using the mainforms WebFormCreate doing something like this:
lCookies := TCookies.Create;
try
lCookies.GetCookies;
lCookie := lCookies.Find('jwt');
if not assigned(lCookie) then
begin
newform := TForm4.Create(Self);
newform.Popup := false;
await(TForm4, newform.Load());
try
// excute form and wait for close
await(TModalResult, newform.Execute);
finally
newform.Free;
end;
But this way it is not working. I assume that it is not valid to use this code in the FormCreate method. Using a Timer with the OnTimer-Event it works fine. But then the mainform is shown for a small amount of time before the LoginForm is shown. What would be the best practice to show the mainform, if a JWT ist present and to show the LoginForm if not?
Regards
Harald