How it works...
In the FormCreate event, the LoginForm is registered as the Subscriber in the publish/subscribe mechanism of DEB. This means that, thanks to the OnUserAuthentication(AEvent: TAuthenticationEvent); and Subscribe(TThreadMode.Main) attribute, when an event of type TAuthenticationEvent is fired in DEB, this method will be executed. Furthermore, specifying TThreadMode as a main, it is ensured that the thread in which that method will be executed is the main thread (UI manipulation must be executed in the main thread).
In the DoLogin method of TRESTAPIService, the authentication call has been implemented: TThread.Sleep simulates a lengthy operation like an HTTP call, and then authentication is successful, if the username corresponds ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access