Improved js registration/login flow