From 5cc56682c49c017e391d42f7e8a6b81e890ddb4c Mon Sep 17 00:00:00 2001 From: Mathias Biilmann Christensen Date: Fri, 29 Sep 2017 11:39:45 +0200 Subject: Better invite/login handling This improves the app.js script so we no longer redirect to /admin when you're already logged in and navigate to any other page --- src/js/app.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/js/app.js b/src/js/app.js index 31623bb..cf2cb36 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -1,6 +1,10 @@ // JS Goes here - ES6 supported -if (window.netlifyIdentity && !window.netlifyIdentity.currentUser()) { - window.netlifyIdentity.on('login', () => { - document.location.href = '/admin/'; +if (window.netlifyIdentity) { + window.netlifyIdentity.on("init", user => { + if (!user) { + window.netlifyIdentity.on("login", () => { + document.location.href = "/admin/"; + }); + } }); } -- cgit v1.3