Changed checking whether or not a user was passed from $user !== null to $user->getAuthIdentifier() !== null