Search code examples
shopify-apishopify-template

Headless Shopify - Reest Password Token Email


I'm in the process of building a headless implementation of Shopify+. I'm trying to setup the shopify email reset notification to redirect back to my site (in this case just localhost) but I need it to also pass the recovery token. I can't find any documentation on how to get only the token in the email template. I want to replace the link below with something like http://localhost:8449/auth/reset/{{ ??resettoken?? }}.

My question is how do I get just the token part without the URL in the Liquid email template? And is there a documentation somewhere I should follow for this?

enter image description here


Solution

  • You can use the split tag and extract the token, please check the below code.

    {% assign resetUrlData = customer.reset_password_url | split: "/" %}
    {% assign resetUrl = "http://localhost:8449/auth/reset/" | append: resetUrlData[6] %}
    

    Add this code on the top of the template or before the start of the table tag, or anywhere in the code where you want, and after that replace the "Reset your password link" anchor tag code with the below code.

    <a href="{{ resetUrl }}" class="button__text">Reset your password</a>