Skip to content

Instantly share code, notes, and snippets.

@Khaledgarbaya
Created January 8, 2021 11:45
Show Gist options
  • Save Khaledgarbaya/d5425ef359b2ea5edee5424f7cc35525 to your computer and use it in GitHub Desktop.
Save Khaledgarbaya/d5425ef359b2ea5edee5424f7cc35525 to your computer and use it in GitHub Desktop.
Refersh netlify identity
netlifyIdentity.on('init', (user) => {
    if (user) {
      user.jwt(true).then((token) => {
        const parts = token.split('.')
        const currentUser = JSON.parse(atob(parts[1]))
        setUser((user) => ({
          ...user,
          app_metadata: {
            ...currentUser.app_metadata,
          },
        }))
      })
    }
  })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment