Move Netlify Identity to script src
This commit is contained in:
parent
90ceeb5dea
commit
5f5fdd5d2e
3 changed files with 13 additions and 16 deletions
|
|
@ -29,5 +29,18 @@
|
|||
To begin the development, run `npm start`.
|
||||
To create a production bundle, use `npm run build`.
|
||||
-->
|
||||
<script src="https://identity-js.netlify.com/v1/netlify-identity-widget.js"></script>
|
||||
<script>
|
||||
// check for netlifyIdentity, redirect to admin if user is logging in
|
||||
if (window.localStorage && window.netlifyIdentity) {
|
||||
netlifyIdentity.on('init', user => {
|
||||
if (!user) {
|
||||
netlifyIdentity.on('login', () => {
|
||||
document.location.href = '/admin/'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import React from 'react'
|
|||
import { render } from 'react-snapshot'
|
||||
import App from './App'
|
||||
import registerServiceWorker from './registerServiceWorker'
|
||||
import './netlifyIdentity'
|
||||
import 'normalize.css'
|
||||
import './globalStyles.css'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
import netlifyIdentity from 'netlify-identity-widget'
|
||||
|
||||
// check for netlifyIdentity, redirect to admin if user is logging in
|
||||
netlifyIdentity.on('init', user => {
|
||||
if (!user) {
|
||||
netlifyIdentity.on('login', () => {
|
||||
document.location.href = '/admin/'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
if (window.localStorage) {
|
||||
netlifyIdentity.init()
|
||||
window.netlifyIdentity = netlifyIdentity
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue