Improved auto-login logic. Logged user is stored in local storage.