Refactors authentication to happen at the JS pre-render level.