As we already discussed, we need to extend the API to be able to validate the credentials of a user and return a proper response to the client.
The requirements at the API level are as follows:
Add a new endpoint called
/api/users/login
Process the information posted there to check the credentials using bcrypt, which we already discussed in Chapter 10, Sign Up.
As we did in the previous chapter, we are going to work on the Users
module, and we will add a new controller. The following screenshot shows us how the folders are organized:
We need to do a couple of changes in this file to receive requests, with the following code:
'login' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/api/users/login', 'defaults' => array( 'controller' => 'Users\Controller\Login' ), ), ),
This is the new route we need to declare...