Database Reference
In-Depth Information
public User
getByUserName
(string username)
{
User u = null;
Node<User> n = _graphClient.Cypher
.Match(" (user:User {username:{user}} ) ")
.WithParam("user", username.ToLower())
.Return(user => user.As<Node<User>>())
.Results.Single();
// set user
u = n.Data;
// set node id
u.noderef = n.Reference;
return u;
}
}}
Login
This section reviews the login process for the sample application. To execute the login process, use the
LoginController
as well as the
User
and
UserService
classes. Before reviewing the controller and service layer, take a
quick look at the front-end code for the login.
Login Form
The HTML required for the user login form is shown in Listing 7-19 and can be found in the
{PROJECTROOT}/Views/_
Home.cshtml
layout file. Again, one important item to note in the HTML form is that the
graphStory
object then
class name
then
property
are used to specify what is passed to controller and, subsequently, to the service layer for
querying the database.
Listing 7-19.
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="
graphStory.user.username
" class="form-control">
</div>
<button type="submit" class="btn btn-success">Sign in</button>
</form>