RAD Studio
ContentsIndex
PreviousUpNext
Login Pages

Of course, your Websnap application also needs a login page. Users enter their username and password for authentication, either while trying to access a restricted page or prior to such an attempt. The user can also specify which page they receive when authentication is completed. If the username and password match a user in the Web user list, the user acquires the appropriate access rights and is forwarded to the page specified on the login page. If the user isn't authenticated, the login page may be redisplayed (the default action) or some other action may occur. 

Fortunately, WebSnap makes it easy to create a simple login page using a Web page module and the adapter page producer. To create a login page, start by creating a new Web page module. Choose FileNewOther, and select WebSnap from the Delphi Projects folder. In the right pane of the New Items window select the WebSnap Page Module. Select AdapterPageProducer as the page producer type. Fill in the other options however you like. Login tends to be a good name for the login page. 

Now you should add the most basic login page fields: a username field, a password field, a selection box for selecting which page the user receives after logging in, and a Login button which submits the page and authenticates the user.

To add these fields:

  1. Add a TLoginFormAdapter component (which you can find on the WebSnap category of the Tool Palette) to the Web page module you just created.
  2. Double-click the AdapterPageProducer component to display a Web page editor window.
  3. Right-click the AdapterPageProducer in the top left pane and select New Component. In the Add Web Component dialog box, select AdapterForm and click OK.
  4. Add an AdapterFieldGroup to the AdapterForm. (Right-click the AdapterForm in the top left pane and select New Component. In the Add Web Component dialog box, select AdapterFieldGroup and click OK.)
  5. Now go to the Object Inspector and set the Adapter property of your AdapterFieldGroup to your LoginFormAdapter. The UserName, Password and NextPage fields should appear automatically in the Browser tab of the Web page editor (accessed by double clicking the AdapterPageProducer) .
So, WebSnap takes care of most of the work in a few simple steps. The login page is still missing a Login button, which submits the information on the form for authentication.

To add a Login button:

  1. Add an AdapterCommandGroup to the AdapterForm.
  2. Add an AdapterActionButton to the AdapterCommandGroup. Change its DisplayComponent to AdapterFieldGroup using the Object Inspector.
  3. Click on the AdapterActionButton (listed in the upper right pane of the Web page editor) and change its ActionName property to Login using the Object Inspector. You can see a preview of your login page in the Web page editor's Browser tab.
If the button doesn't appear below the AdapterFieldGroup, make sure that the AdapterCommandGroup is listed below the AdapterFieldGroup on the Web page editor. If it appears above, select the AdapterCommandGroup and click the down arrow on the Web page editor. (In general, Web page elements appear vertically in the same order as they appear in the Web page editor.) 

There is one more step necessary before your login page becomes functional. You need to specify which of your pages is the login page in your end user session adapter. To do so, select the EndUserSessionAdapter component in your Web application module. In the Object Inspector, change the LoginPage property to the name of your login page. Your login page is now enabled for all the pages in your Web server application.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!