Server authentication with Passport, fix race condition