[Common Issue] Netlify CMS & Git Gateway - Email not confirmed

Great! You’ve set up a site using Netlify CMS and Git Gateway. You’ve followed the Identity docs instructions and set up Git Gateway. You’ve invited some users and opened the invitation link from the generated emails but as you try to log in you get the following error message:

Email not confirmed

hTf9VI1

So what’s happening? You probably added the identity widget to the /admin/ page of your site. By default, however, the identity emails point to the root of your website. Time to do something about it! Here’s two solutions:

  1. Add the identity widget to your homepage <head>. Upside of this method is that it’s fast and easy, no other configuration needed. The downside is that all of your users are downloading the widget while they might not need it. That’s kb’s wasted. Unless you’re using Netlify Identity for something else than the authentication of CMS users, I recommend you utilize solution #2.

  2. Change the invitation emails! This takes a bit more time, but it’s probably the cleanest solution. You already have the identity widget loaded at your admin/ page, so you might as well have your users confirm their email there. Learn how to update your invitation emails here: https://docs.netlify.com/visitor-access/identity/identity-generated-emails/#email-templates

For Netlify CMS, these are the templates to use. You will have to tell you SSG not to add a layout to these templates (there shouldn’t be any <html>, <head> or <body> tags for these pages).

confirmation.html

<h2>Confirm your signup</h2>

<p>Follow this link to confirm your user:</p>
<p><a href="{{ .SiteURL }}/admin/#confirmation_token={{ .Token }}">Confirm your mail</a></p>

recovery.html

<h2>Reset Password</h2>

<p>Follow this link to reset the password for your user:</p>
<p><a href="{{ .SiteURL }}/admin/#recovery_token={{ .Token }}">Reset Password</a></p>

invitation.html

<h2>You have been invited</h2>

<p>You have been invited to create a user on {{ .SiteURL }}. Follow this link to accept the invite:</p>
<p><a href="{{ .SiteURL }}/admin/#invite_token={{ .Token }}">Accept the invite</a></p>

email-change.html

<h2>Confirm Change of Email</h2>

<p>Follow this link to confirm the update of your email from {{ .Email }} to {{ .NewEmail }}:</p>
<p><a href="{{ .SiteURL }}/admin/#email_change_token={{ .Token }}">Change Email</a></p>

Try resending the confirmation email from the admin panel. If you do encounter any problems after you have made these changes, please open a new post on this forum and someone will try to help you troubleshoot the issue.

6 Likes

This is fantastic information, @tomrutgers, and we cannot thank you enough for creating this! :smiley:

1 Like

Trying to set up a Hugo install with Netlify CMS. It automatically sent the Invitation, but it just takes me to the website itself. When I manually go to mywebsite.domain/admin it gives me the “email not confirmed” error.

If this article addresses my issue, where exactly do I put these email templates?

Also, Why doesn’t it just work when using Netlify’s tools? Why do I need to create new email templates?

The default behavior is that the invite link would point you to your main page where you’ll need to have the netlify-identity-widget installed as well. This article shows you how to avoid installing the widget on your main page. Basically, you need to do this step: https://www.netlifycms.org/docs/add-to-your-site/#add-the-netlify-identity-widget.

1 Like

Hey @Dennis, Thanks for the help! Because I used the Netlify CMS automagic Hugo installation method (under “start with a template”) these snippets are already present in my template files, and have been since the beginning.

Please advise what you would do in this case.

Here’s how the scripts are in the templates automatically:

site > partials > head.html and src > cms.html contains:

{{ if .IsHome }}
    <script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
{{ end }}

site > partials > footer.html contains:

<script src="/app.js"></script>

and src > js > app.js contains:

if (window.netlifyIdentity) {
    window.netlifyIdentity.on("init", (user) => {
        if (!user) {
            window.netlifyIdentity.on("login", () => {
                document.location.href = "/admin/";
            });
        }
    });
}

src > cms.html contains (in the head tags without any conditional handlebar tags):

<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>

Ok I figured it out. It appears there’s a bug in the system if you’re already logged in to Netlify. If I copy/paste the tokened link from the email into a “Private Window”, it works as intended. This is an unfortunate behavior.

1 Like

This isn’t standard behavior, try clearing your cache or unregistrering any serviceworkers.

Thanks @logangreer - your solution worked for me as well. I got the link in my email as:

https://.netlify.app/#invite_token=

I followed your advice and opened an incognito window and pasted a modified version of the link, inserting “admin” as follows:

https://.netlify.app/admin/#invite_token=

Afterwards, I was able to set my password and log in to the CMS just fine. Previously, when I was trying to accept the invite (with an active Netlify session in my browser), I got an error that said “Branch name not found”.