Database Reference
In-Depth Information
Figure 8-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
getByUsername
method in the
User
class. As shown in the Listing 8-21, the result of the
g getByUsername
method is assigned to the
user
variable.
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.
Listing 8-21.
The
getByUsername
Method in the
User
Class
public static function getByUsername($username)
{
$userlabel = Neo4Client::client()->makeLabel('User');
$nodes= $userlabel->getNodes('username', $username);
if (empty($nodes) || count($nodes)==0) {
return null;
}else{
return self::fromArray($nodes[0]);
}
}
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.