Single-tier IntraWeb and RemObjects DataAbstract server PDF Print E-mail
Written by Bernhard Fischer   
Tuesday, 20 February 2007
Article Index
Single-tier IntraWeb and RemObjects DataAbstract server
Page 2
Page 3
Page 4
Page 5
Page 6
Page 7
Page 8


Now fill the OnClick event for the Login button. There is a basic check for the username and password length before our LoginService is called. Last but not least we also fetch the login time from our TimeService to display it on the next web page and store it in the user's session. Because we are displaying information on web pages, we have to convert our services' results to strings. This could have been implemented in the services themselves. But to have a logical border, and to be able to use the services in a non-IW scenario, we do it in the web forms of our IW application.


[click to collapse source code]

 
 unit uFrmLogin;
 
 {PUBDIST}
 
 interface
 
 uses
  IWAppForm,
  IWApplication,
  IWTypes,
  IWCompLabel,
  IWCompButton,
  Classes,
  Controls,
  IWControl,
  IWCompEdit,
  uFrmContent;
 
 type
  TfrmLogin = class(TIWAppForm)
    editName: TIWEdit;
    editPassword: TIWEdit;
    buttonLogin: TIWButton;
    IWLabel1: TIWLabel;
    IWLabel2: TIWLabel;
    procedure buttonLoginClick(Sender: TObject);
    procedure IWAppFormCreate(Sender: TObject);
  public
    FfrmContent: TfrmContent;
 end;
 
 implementation
 {$R *.dfm}
 
 uses
  uServerController,
  IWRODALibrary_Intf,
  uSessionDataModule;
 
 procedure TfrmLogin.buttonLoginClick(Sender: TObject);
 begin
  with UserSession do
  begin
    if ((Length(editName.Text) < 3) or (Length(editPassword.Text) < 3)) then
    begin
      WebApplication.ShowMessage('Username / password too short');
      exit;
    end;
    if CoLoginService.Create(SessionDataModule.messageSession,
      SessionDataModule.channelLocal).Login(editName.Text, editPassword.Text) then
      begin
        Username := editName.Text;
        LoginTime := CoTimeService.Create(SessionDataModule.messageSession,
        SessionDataModule.channelLocal).GetTime;
        FfrmContent.Show;
      end;
  end;
 end;
 
 
 procedure TfrmLogin.IWAppFormCreate(Sender: TObject);
 begin
  FfrmContent := TfrmContent.Create(WebApplication);
 end;
 
 end.
 
 


We are ready now - let's compile and run the application. This is what the server will show you in your browser:

click to enlarge


After you could be authenticated, your username and login time is shown on a new page.

click to enlarge


Additionally, you can view the table of users from the database.

click to enlarge




Last Updated ( Friday, 18 January 2008 )
 
Next >