Refactor login server code

This allows a server to use different login server URIs for handling
different actions. This is mainly intended to be potentially used by
the main server.