How to use the netlify-identity-widget.on function in netlify-identity-widget

To help you get started, we’ve selected a few netlify-identity-widget examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jinksi / hyperstatic / src / netlifyIdentity.js View on Github external
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()
}
github uptownhr / hackable / web / pages / index.vue View on Github external
mounted () {
      netlifyIdentity.on('init', user => this.login(user))
      netlifyIdentity.on('login', user => this.login(user))
      netlifyIdentity.on('logout', () => console.log('Logged out'))
      netlifyIdentity.on('error', err => console.error('Error', err))
      netlifyIdentity.on('open', () => console.log('Widget opened'))
      netlifyIdentity.on('close', () => console.log('Widget closed'))

      netlifyIdentity.init()
      const userx = netlifyIdentity.currentUser()

      console.log('hi', userx)



    },
github PrefectHQ / prefect / docs / .vuepress / theme / Layout.vue View on Github external
mounted() {
    const netlifyIdentity = require("netlify-identity-widget");

    netlifyIdentity.init()
    netlifyIdentity.on('init', this.logIn )
    netlifyIdentity.on('login', this.logIn )
    netlifyIdentity.on('logout', this.logOut)

    const user = this.getUser()
    if (user) {
      this.logIn(user)
    }

    this.$router.beforeEach((to, from, next) => {
      const user = this.getUser()
      if (user) {
        this.logIn(user)
      } else {
        this.logOut(user)
      }
      next()
    })
github PrefectHQ / prefect / docs / .vuepress / theme / Layout.vue View on Github external
mounted() {
    const netlifyIdentity = require("netlify-identity-widget");

    netlifyIdentity.init()
    netlifyIdentity.on('init', this.logIn )
    netlifyIdentity.on('login', this.logIn )
    netlifyIdentity.on('logout', this.logOut)

    const user = this.getUser()
    if (user) {
      this.logIn(user)
    }

    this.$router.beforeEach((to, from, next) => {
      const user = this.getUser()
      if (user) {
        this.logIn(user)
      } else {
        this.logOut(user)
      }
      next()
    })
  }
github ejarzo / Shape-Your-Music / src / context / CurrentUserContext / CurrentUserContextProvider.js View on Github external
logout = callback => {
    netlifyIdentity.logout();
    netlifyIdentity.on('logout', () => {
      this.setState({ user: null });
    });
  };
github diegonvs / gatsby-boilerplate / src / services / auth.js View on Github external
return new Promise((resolve, reject) => {
        if (isLoggedIn()) {
            resolve();
        } else {
            netlifyIdentity.open();
            netlifyIdentity.on('login', user => {
                netlifyIdentity.close();
                resolve();
            });
        }
        netlifyIdentity.on('error', err => {
            reject(err);
        });
    });
}
github gatsbyjs / gatsby / packages / gatsby-plugin-netlify-cms / src / cms-identity.js View on Github external
const addLoginListener = () =>
  netlifyIdentityWidget.on(`login`, () => {
    document.location.href = `${__PATH_PREFIX__}/${CMS_PUBLIC_PATH}/`
  })
github snipcart / gatsby-netlify-serverless / src / pages / index.js View on Github external
componentDidMount(){
        netlifyIdentity.on("login", user => this.updateProducts());
        netlifyIdentity.on("logout", () => this.updateProducts());
        this.updateProducts();
    }
github diegonvs / gatsby-boilerplate / src / services / auth.js View on Github external
return new Promise((resolve, reject) => {
        netlifyIdentity.logout();
        netlifyIdentity.on('logout', () => {
            resolve();
        });
    });
}
github ejarzo / Shape-Your-Music / src / context / CurrentUserContext / CurrentUserContextProvider.js View on Github external
authenticate = ({ showSignup = false, onSuccess }) => {
    netlifyIdentity.open(showSignup && 'signup');
    netlifyIdentity.on('login', user => {
      this.setState({ user });
      onSuccess && onSuccess(user);
    });
  };

netlify-identity-widget

Netlify Identity widget for easy integration

MIT
Latest version published 3 years ago

Package Health Score

62 / 100
Full package analysis