DoSomething/user-api — pull request #6 by codal-sara (2014-12-01 16:37:07+00:00)
Title: Feature

#### What's this PR do?
1. Allows the ability the for a user to submit a campaign signup by POSTing to the /campaigns/:nid/signup endpoint. This creates a new Campaign collection via the Campaign model with the given node ID, generates the sid, and sets up an embedded relationship with the User model.
2. Creates ability to retrieve all campaigns for a given user using the GET method by passing the user's drupal id, id, email or mobile number as a query parameter.
3. Introduces /login and /logout endpoints that will give user access to submitting/updating a campaign. A Token model is created that generates a token key for the authenticated user. I have created a corresponding filter, "auth.token" that checks if the token is set in the "Session" header before allowing access to the campaign resource.
4. I added mutators in the User model to convert emails to lowercase and hash the password instead of doing it in the user controller for the POST and PUT methods.

#### Where should the reviewer start?
In the routes.php file where I have defined new routes such as /login, /logout and /campaigns/{id}/signup. From there I have created a new controller, CampaignController.php which includes the methods for retrieving and submitting a campaign. There are also 2 new models: Token.php generates the token and relationship with the User's id and Campaign.php. The auth.token filter is located in the app/filters.php file.

#### How should this be manually tested?
Use Curl (or alternatively Postman or Fiddler) to test the endpoints:

POST /login,
POST /logout
POST /campaigns/123/signup
GET /users/campaigns?email=test@dosomething.org

#### Any background context?
I have currently disabled the auth.token filter for testing, since the "Session" header will need to be provided by the consumer.