Refactor authenticate to service