How to use gotrue-js - 2 common examples

To help you get started, we’ve selected a few gotrue-js 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 netlify / create-react-app-lambda / src / useNetlifyIdentity.js View on Github external
export function useNetlifyIdentity(domain, onAuthChange = () => {}) {
  const authRef = React.useRef(
    new GoTrue({
      APIUrl: `${domain}/.netlify/identity`,
      setCookie: true
    })
  );

  const [user, setUser] = React.useState(null);
  const _setUser = _user => {
    setUser(_user);
    onAuthChange(_user); // if someone's subscribed to auth changes, let 'em know
    return _user; // so that we can continue chaining
  };
  /******* OPERATIONS */
  // make sure the Registration preferences under Identity settings in your Netlify dashboard are set to Open.
  const signupUser = (email, password) =>
    authRef.current.signup(email, password).then(_setUser); // TODO: make setUser optional?
  const loginUser = (email, password) =>
github netlify / netlify-cms / packages / netlify-cms-backend-git-gateway / src / implementation.js View on Github external
this.netlifyLargeMediaURL = getEndpoint(
      config.getIn(['backend', 'large_media_url'], defaults.largeMedia),
      netlifySiteURL,
    );
    const backendTypeRegex = /\/(github|gitlab|bitbucket)\/?$/;
    const backendTypeMatches = this.gatewayUrl.match(backendTypeRegex);
    if (backendTypeMatches) {
      this.backendType = backendTypeMatches[1];
      this.gatewayUrl = this.gatewayUrl.replace(backendTypeRegex, '');
    } else {
      this.backendType = null;
    }

    this.authClient = window.netlifyIdentity
      ? window.netlifyIdentity.gotrue
      : new GoTrue({ APIUrl });
    AuthenticationPage.authClient = this.authClient;

    this.backend = null;
  }

gotrue-js

GoTrue API client for JavaScript

MIT
Latest version published 3 years ago

Package Health Score

64 / 100
Full package analysis

Popular gotrue-js functions