Skip to content

Login/Logout

In this scenario, we'll see how to set up a mechanism to login/logout with Bluage.

Model

Create 2 entities: AppUser and Role and their associated business objects.

In the entity AppUser:

  • Apply the stereotypes "identifier" and "userid" to the attribute login.

  • Apply the stereotype "password" to the attribute password.

In the entity Role:

  • Apply the stereotype "identifier" to the attribute id.

  • Apply the stereotype "role" to the attribute roleName.

LoginLogout1

Create the view objects:

LoginLogout2

Create a user case diagram in the PK_ROLES folder:

LoginLogout3

In the service layer, will create two service for the authentication:

LoginLogout4

Login service

  • Apply the stereotypes "login" and "JsonController" to it.

  • Apply the stereotype "JsonService" to the method login.

This method takes as a parameter an object of type "AppUserBO" and returns an object of type "AppUserBO".

Logout service

  • Apply the stereotypes "logout" and "JsonController" to it.

  • Apply the stereotype "JsonService" to the method logout.

This method don’t takes a parameters and returns a void.

Create one ServiceApplication in the view layer:

LoginLogout5

  • Apply the stereotype "application" to it.

  • Add one property isLogged with false as default value.

  • The service has two methods:

  • getLogged with the stereotype "ProcessOperation".

LoginLogout6

The method returns the value of the isLogged property.

  • setLogged with the stereotype "ProcessOperation"

LoginLogout7

The method as a parameter of type boolean which is assigned to the isLogged property.

In the view layer create a login screen inside a login user case:

LoginLogout8

The screen have:

  • The properties appUser of type AppUserVO and pnlLoginForm of type Object.
  • A principal panel named like the panel in the application shell.

  • A Label named loginLabel with the text "Login".

  • An Input text txtLogin with the tags:

    • Binding Group

      • colProperty = login

      • instance = appUser

    • UiSimpleValidation

      • valMessage = "Login is required".

      • valRequired = true

  • A Text msgTxtLogin with the stereotype Message and the tag forId = txtLogin.

  • A Label named passwordLabel with the text "Password".

  • An Input text txtPassword with the tags:

    • Binding Group

      • colProperty = password

      • instance = appUser

    • UiSimpleValidation

      • valMessage = "Password is required"

      • valRequired = true

  • A Text msgTxtPassword with the stereotype Message and the tag forId = txtPassword.

  • A Button btnLogin with the text "Login".

  • An event btnLoginEventClick associated to btnLogin

LoginLogout9

The event btnLoginEventClick:

LoginLogout10

The login method returns an object of type AppUserBO or is the validation fails throws one exception.

If the validation is success the method setLogged is executed and the the apps is redirect to startview.

For the logout add an event btnLogoutEventClick in the main screen associated with a button logout:

LoginLogout11

The method logout returns void, setLogged assigns false to the property isLogged ant the apps navigate to the login screen.