{% assign assigned = customer.metafields.custom.assigned_portal.value %}
{% if customer %}
{% if assigned == blank or assigned.system.handle != b2b_portal.system.handle %}
{% comment %} If they have the wrong portal or no portal, send to account {% endcomment %}
{% endif %}
{% else %}
{% comment %} If not logged in at all, send to login {% endcomment %}
{% endif %}