Access Control & Personalization: Login

IFML Modeling with WebRatio Mobile Platform
795 views Published on Apr 03, 2015 | Time 4 min
Applies to: 8.0 or higher

The "Login" is the operation that allows the users to access to protected resources in a mobile app. We need to define a place for users to insert and validate their credentials and the business logic for the Login. In this lesson you learn how to model the basic "Login" feature, both for standalone mobile apps and for mobile apps working with a back-end, using WebRatio Mobile Platform.

Transcript

Table of contents

How to Model the Offline Login

Let's start considering the case we want to create a standalone mobile app providing a Login Screen in order to make the user access to the protected resources.

Let's start creating a new Mobile Project. Click "File", then choose the "New" option and then the "Mobile Project" option. Enter a name for the Mobile Project, then check the "Create default model for login and home" option. By enabling this option WebRatio Mobile Platform automatically will create a IFML model containing the Login Screen with its Login Action and the default Home Screen. Press the "Finish" button to complete the process.

Let's have a look to the "CRM" mobile project we have just created. Move to the "App View". The "CRM" mobile project provides the "Login" screen containing the "Login" form that allows the user to enter his credentials. The "Login" action, mapped on the "Login" action definition also provided by the "CRM" mobile project. Double-Click on the "Login" action: the "Login" action definition contains the model necessary to perform the login in the mobile app. Move back to the "App View". The "Home" screen is a protected screen set as the Home screen in the App View. This empty screen can be reached by the user only if the login is successfully performed.

How to Emulate the "Login" feature

We can test now the model provided by the "CRM" mobile project. Press the "Generate and Run" button. In the "Login" screen enter username and password and press the "Login" button. Once the login is completed the empty home screen will appear.

How to Publish the Login Service

Let's consider now the case we want create a mobile app having a back-end. In order to model the "Login" pattern we need a back-end publishing the "Login" user service.

Let's start from our "CRMback-end" dataservice project where we will enable all the service we need in order to allow the user login. Open the Domain Model View, right-click on "User Services" item in the Outline View, and choose "Configure Services...". In the opening dialog enable the "Login" service and press the "OK" button.

Remember that, in order to work correctly, the back-end Domain Model must be mapped to an existing database and properly synchronized with it. Refer to the dedicated lesson to learn more about the database synchronization procedure.

Let's synchronize the Domain Model: right-click on the "CRM" database item and launch the "Synchronize..." command. Export all the objects returned by the synchronization process and press the "Next" button. Finally press the "Finish" button. Once the Domain Model is properly synchronized, let's Generate and Run the DataService Project.

How to Connect with the Back-End

Once we have a listening back-end, let's go back to the "CRM" mobile project. In order to let the mobile app work properly, we need to set the "Back-end Base URL" and make it refer to the "CRMback-end" generated application.

We need to map the Domain Model of the Mobile Project on the one defined in the DataService Project, so that the mobile application can make requests to the published services.

Move to the Domain Model View. Right-click on the "App User" class, select the "Synchronize Domain Model..." option and choose the "CRMback-end" dataservice project. Press the "Next" button, then press the "Import All Elements" button and finally press the "Finish" button.

As you can see the "App User" class now contains the "remoteOid" attribute. This means that it is now mapped to the corresponding "User" class belonging the back-end project.

How to Emulate the "Login" feature

Once the Domain Model is properly mapped, we can generate the IFML model contained in the "CRM" mobile project and test the Login Pattern based on a back-end. Press the "Generate and Run" button. In the "Login" screen enter username and password and press the "Login" button.

During the authentication phase the credentials entered by the user are used to check if he is already registered in the back-end database. When this operation ends successfully, the user can access to the protected home screen.