Pulled out all authentication code to authService