Move authentication logic into AuthService