Frontend form to change Craft Commerce user's password? I'm trying to modify Craft 3's example 'Change password' form to work with a logged in Commerce 2 user, and have copied that code to templates/setpassword.twig.

Two problems...

(1) The {{ code }} and {{ id }} variables throw Don't exist errors.  

(2) If I comment those variables out, I get a Page not found/"Unable to resolve the request: users/setPassword" error when submitting the form.

Clearly I'm doing this totally wrong ... can anyone set me straight?

&lt;form method="post" accept-charset="UTF-8"&gt;
{{ csrfInput() }}
&lt;input type="hidden" name="action" value="users/set-password"&gt;
&lt;input type="hidden" name="code" value="{{ code }}"&gt;
&lt;input type="hidden" name="id" value="{{ id }}"&gt;

&lt;h3&gt;&lt;label for="newPassword"&gt;New Password&lt;/label&gt;&lt;/h3&gt;
&lt;input id="newPassword" type="password" name="newPassword"&gt;
{% if errors is defined %}
    &lt;ul class="errors"&gt;
        {% for error in errors %}
            &lt;li&gt;{{ error }}&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% endif %}

&lt;input type="submit" value="Submit"&gt;
The code you are currently using is for the Set Password form that is used when a user forgets their password and you send them a Password reset email as documented at https://docs.craftcms.com/v3/dev/examples/set-password-form.html.

Here is what I'm using to allow users to change their passwords on demand. It is based on the User Profile Form documented at https://docs.craftcms.com/v3/dev/examples/user-profile-form.html

&lt;form method="post" accept-charset="UTF-8"&gt;
    {{ csrfInput() }}
    &lt;input type="hidden" name="action" value="users/save-user"&gt;
    {# Change to suit your needs #}
    {{ redirectInput('users/'~currentUser.username) }}
    {# Get logged-in user's ID #}
    &lt;input type="hidden" name="userId" value="{{ currentUser.id }}"&gt;

    {% macro errorList(errors) %}
        {% if errors %}
            &lt;ul class="errors"&gt;
                {% for error in errors %}
                    &lt;li&gt;{{ error }}&lt;/li&gt;
                {% endfor %}
            &lt;/ul&gt;
        {% endif %}
    {% endmacro %}

    {% from _self import errorList %}

    {# Enter current password #}
    &lt;h3&gt;&lt;label for="password"&gt;Current Password&lt;/label&gt;&lt;/h3&gt;
    &lt;input id="password" type="password" name="password"&gt;

    {% if account is defined %}
        {{ errorList(user.getErrors('password')) }}
    {% endif %}

    {# Enter new password #}
    &lt;h3&gt;&lt;label for="newPassword"&gt;New Password&lt;/label&gt;&lt;/h3&gt;
    &lt;input id="newPassword" type="password" name="newPassword"&gt;

    {% if account is defined %}
        {{ errorList(user.getErrors('newPassword')) }}
    {% endif %}

    &lt;input type="submit" value="Submit"&gt;
&lt;/form&gt;


UPDATE: updated form to include error handling.