Encapsulate login and redirect if successful login