Wondering what’s next for npm?Check out our public roadmap! »

    netlify-auth-js

    0.5.5 • Public • Published

    Netlify Auth JS Client

    This is a JS library for Netlify Auth API.

    It lets you signup and authenticate users and is a building block for constructing the UI for signups, password recovery, login and logout.

    Usage

    import NetlifyAuth from 'netlify-auth-js'
     
    const auth = new NetlifyAuth({
      APIUrl: 'https://auth.netlify.com'
    });
     
    auth.signup(username, email).then(
      (response) => console.log("Confirmation email sent"),
      (error) => console.log("Error during signup: %o", error.msg)
    );
     
    auth.confirm(token).then(
      (user) => console.log("Logged in as %s", user.email),
      (error) => console.log("Failed to log in: %o", error)
    );
     
    auth.login(email, password).then(
      (user) => console.log("Logged in as %s", user.email),
      (error) => console.log("Failed to log in: %o", error);
    )
     
    auth.requestPasswordRecovery(email).then(
      (response) => console.log("Recovery email sent"),
      (error) => console.log("Error sending recovery mail: %o", error)
    );
     
    auth.recover(token).then(
      (user) => console.log("Logged in as %s", user.email),
      (error) => console.log("Failed to verify recover token: %o", error)
    );
     
    const user = auth.currentUser()
     
    user.update({email: newEmail, password: newPassword}).then(
      (user) => console.log("Updated user"),
      (error) => console.log("Failed to update user: %o", error)
    );
     
    user.jwt().then(
      (token) => console.log("Current token: %s", token),
      (error) => console.log("Failed to get token: %o", error)
    );
     
    user.logout().then(
      (response) => console.log("User logged out"),
      (error) => console.log("Failed to logout user: %o", error)
    );

    Keywords

    none

    Install

    npm i netlify-auth-js

    DownloadsWeekly Downloads

    40

    Version

    0.5.5

    License

    MIT

    Last publish

    Collaborators

    • avatar