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.
Tell the user when their account is being upgraded

Add a message to the login and registration forms when the user is
upgrading their account telling them what's going on and then when the
upgrade is complete show a flash message telling them they have been
upgraded.
Link to the hosting app registration page

The instance app doesn't have a registration page, so we link to the
hosting app's registration from the legacy account upgrade page.