tidy and compress httpauth.php a little, increase preauth priority

We probably want to try quite hard to get to getCurrentUserId()
when we're in state 'preauth', because at that point the client is
holding a very valuable piece of data (the auth token) which we
want to read in and unset in as tight a loop as possible to
reduce the chance of anyone being able to steal it somehow.