<< Click to Display Table of Contents >> Navigation: Technology Overview > Forms and Modules > LoginForm |
LoginForm is another special form type which is solely used for login purposes. If your application contains a LoginForm (any form inheriting from TUniLoginForm), it will be the first form displayed when a Web session starts. A LoginForm can be created with a uniGUI Wizard by following this path: File->New->Other->Delphi Projects->uniGUI for Delphi->Form.
uniGUI Wizard
Create a Login Form
This action will create a blank LoginForm which looks identical to a regular form:
A blank LoginForm
Sample LoginForm design
A LoginForm is a descendant of a built-in class named TUniLoginForm. Each application can only have one LoginForm. After adding a LoginForm, your application will show this form when a new session starts. You need to add controls, event handlers, everything you need, to implement the required functionality. Login behavior is controlled using form's ModalResult. If LoginForm returns mrOK, it means a successful login, and a new MainForm will be created and activated. When ModalResult returns mrCancel, it will terminate the session. If we use a fake form with just two buttons (one for successful login and other for failure) the following code will do it:
procedure TUniLoginForm1.UniButton1Click(Sender: TObject);
begin
ModalResult := mrOK; // Login is valid so proceed to MainForm
end;
procedure TUniLoginForm1.UniButton2Click(Sender: TObject);
begin
ModalResult := mrCancel; // Invalid Login exit from app
end;
Once the user is logged in and MainForm is displayed, there are two ways to terminate the session. You can terminate the session and return to LoginForm by returning mrOK as ModalResult or terminate the session by returning mrCancel. For security reasons, the existing session is always terminated before displaying the LoginForm, i.e. each new login starts a new session.