diff options
| author | Mathias Biilmann Christensen <info@mathias-biilmann.net> | 2017-09-29 11:39:45 +0200 |
|---|---|---|
| committer | Mathias Biilmann Christensen <info@mathias-biilmann.net> | 2017-09-29 11:39:45 +0200 |
| commit | 5cc56682c49c017e391d42f7e8a6b81e890ddb4c (patch) | |
| tree | e457083976674b71e5a1b65188d7f7d449feb3ff | |
| parent | e9a67ff28a14e65f2d01a2d5b6f333e7b009777a (diff) | |
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
| -rw-r--r-- | src/js/app.js | 10 |
1 files 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/"; + }); + } }); } |
