Prompt user to upgrade their legacy account

When a legacy account is detected take the user to an upgrade page which
allows them to associate their legacy instance with a new-style account.
Fix auth tests

Make sure the login route redirects upon success and the logout route
exists.
Simplify auth tests

supertest provides a variety of ways to assert the headers and body of
the response are correct, so use those rather than doing comparisons in
the 'end' callback.
Upgrade user's account after successful login or registration

When a user successfully logs in or registers after being prompted to
create an account create a new permission document which links their
account to the instance being upgraded. This uses the
legacyAccountUpgrade middleware, which looks for a legacyInstanceId in
the session and if found uses it to create appropriate permissions.