{#- A user's password policy: which applies and why, with pin and unpin. Expects user and password_policy (spark.web.endpoints.password_policies.user_context). -#}
Password policy
{% if not password_policy.applies %}

{{ password_policy.note }}

{% else %} {% set p = password_policy %}
Why{% if p.source == "pin" %}pinned on this user{% elif p.source == "role" %}the {{ p.role }} role maps to it{% else %}no role maps to another policy, so the default applies{% endif %}
{% if p.tier %}
Password tier{{ p.tier }}
{% endif %} {% if p.expires_at %}
Must change by{{ p.expires_at.strftime("%Y-%m-%d") }}
{% endif %} {% if p.change_reason %}
A new password is required{{ p.change_reason.value|replace("_", " ") }}
{% endif %}
{% if p.source == "pin" %}
{% endif %}
{% endif %}