String username = request.getParameter("username");
String password = request.getParameter("password");
Account account = this.petStore.getAccount(username, password);
if (account == null) {
return new ModelAndView("Error", "message", "Invalid username or password. Signon failed.");
}
else {
UserSession userSession = new UserSession(account);
PagedListHolder myList = new PagedListHolder(this.petStore.getProductListByCategory(account.getFavouriteCategoryId()));
myList.setPageSize(4);
userSession.setMyList(myList);
request.getSession().setAttribute("userSession", userSession);
String forwardAction = request.getParameter("forwardAction");
if (forwardAction != null) {
response.sendRedirect(forwardAction);
return null;
}
else {
return new ModelAndView("index");
}
}