Only bounce users to the login page if they're not logged in

This eliminates a redirect loop where a page the logged-in user doeesn't
have access to redirects them to the login page, which immediately
redirects them back to the page.
fix tests
Merge djmitche/build-relengapi:issue167 (PR #167)