Refactor out verifyCredentials()