Database Reference
In-Depth Information
Login
This section reviews the login process for the sample application. To execute the login process, use the
LoginController and User , UserInterface , and UserImpl classes.
Login Form
The HTML required for the user login form is shown in Listing 11-22 and can be found in the
{PROJECTROOT}/WebContent/mustache/html/global/base-home.html file. Again, the important item to note in the
form is that the bean name and property are used to specify what is passed to controller and, subsequently, to the
service layer for querying the database.
Listing 11-22. The login Form
<form class="navbar-form navbar-right" action="/login" role="form" method="post">
<div class="form-group">
<input type="text" placeholder="Username" name=" user.username " class="form-control">
</div>
<button type="submit" class="btn btn-success">Sign in</button>
</form>
Login Controller
In the LoginController class, you will use a method called login to control the flow of the login process, as shown
in Listing 11-23. The controller instantiates a ModelAndView object and returns properties to the view layer. Next, the
GraphStoryInterface accesses the login method of the UserInterface and returns a GraphStory object.
If no errors are returned during the login attempt, a cookie is added to the response and the request is redirected
to the social home page, as shown in Figure 11-7 . Otherwise, the ModelAndView specifies the HTML page to return and
the error messages that need to be displayed.
Figure 11-7. The Social Graph home page
 
Search WWH ::




Custom Search