Database Reference
In-Depth Information
If the user is found during the login attempt, a cookie is added to the response and the request is redirected via
redirect to the social home page, shown in Figure 10-7 . Otherwise, the route will specify the HTML page to return
and will add the error messages that need to be displayed back to the view.
Figure 10-7. The social graph home page
Login Service
To check to see if the user values being passed through are connected to a valid user combination in the database, the
application uses the get_user_by_user_name method in the User class. As shown in Listing 10-21, the result of the
get_user_by_user_name method is assigned to the user variable.
Listing 10-21. The get_user_by_user_name Method in the User class
def get_user_by_user_name(neo, username)
user=""
users = neo.find_nodes_labeled("User", username: username)
if !!users && users.any?
user = users.first["data"]
end
user
end
If the result is not null or empty, the result is set on the User object and returned to the controller layer of the
application.
Now that the user is logged in, he can edit his settings, create relationships with other users in the graph, and
create his own content.
 
Search WWH ::




Custom Search