Also test the username of the pending user.

Change-Id: I447ab079f71d05373b95b30e511a929d291810a9
Ensure that clearing a non-existent email change is accepted.

While not really a valid request, it makes more sense to just swallow
it & tell the client it's fine, than to reject it.

Change-Id: I3a88aed13452fe1a4c6ee06c23c69f99ed5df46b
Move email change handling from helper functions to a class.

This follows the pattern of the PendingUser interactions with the
sqlite database, and should be easier to extend and otherwise work
with.

Introduce a new intermediate class which handles the age stuff and
then a PendingEmail class which extends that. Also unit tests for
this class. Remove the previous helper methods for email changing,
and replace them with instances of this class.

Change-Id: I579ddfade0e9ef80cb2c129672150e14a784ce44
Fix typo in message to new users.

Change-Id: I56dd0d4c07a6ab9c91162814b284658669fed025
Only allow activation of new users within the first 2 days.

This makes it more likely that a user will actually activate their
account, and thus more likely that they'll remember the details.

Change-Id: I6728d02e64ae95ddc760da05879ccffd2861b60d
Remove obsolete function.

This could have been removed in 621b6c2275ec2cf500 but was missed.

Change-Id: Ie9d24bb81c22abb283048806473e5ee4588cc7e8
Add ability to iterate over all pending items.

Add a class method usable on both the PendingEmail and PendingUser
classes which returns a list of all the Pending* instances that exist
in the database. This is expected to be used for administratative
functionality, like clearing the database from cron.

Change-Id: Ia9fa05deab35489eae2704b544a851fdd212e325
Add a cron helper which clears old requests.

This applies to both email change requests, and to new user requests.
They are removed at the 3 day point (providing a gap to ensure that
we can't remove any requests that might still be valid, and also in
case the user clicks the link in that day - they'll get a nicer error).

In the case of new user requests, the cron task also emails the team
leader that requested the account, to let them know that the request
expired without being activated.

Change-Id: Ibf18341f8d0a75404da9b5e8607b896a5dfb92c6