1.0.10 • Published 2 years ago

@netappsng/react-netapps-sso v1.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Using @netappsng/react-netapps-sso

@netappsng/react-netapps-sso is a React library for integrating with NetApp SSO. This document will guide you through the installation and usage of the library.

Installation

To install the library, run the following command in your terminal:

yarn add @netappsng/react-netapps-sso

or

npm install @netappsng/react-netapps-sso

Usage

To use the library, import useNetAppsSso from the package and use it in your React component.

OptionDefault ValueDescription
displayInAuthErrortrueIf set to true, error messages will be displayed on the authentication modal.
displayLoginButtonOnVerificationfalseIf set to true, a login button will be displayed on the reset password and phone number verification screens.
onReadynullThis callback function is called when the authentication modal is ready.
closenullThis is use to close the auth modal.
onSuccessfulnullThis callback function is called when authentication is successful. The error parameter will contain any error messages if there were any.
onFailednullThis callback function is called when authentication fails. The success parameter will contain any success messages if there were any.

Here is full example

import React from "react";
import { useNetAppsSso } from "@netappsng/react-netapps-sso";

const App = () => {
  const { initAuth, acceptInvite, isReady, close } = useNetAppsSso({
    publicKey: "NA_PUB_TEST-03e37a6509fdc66d478fbaa8926a3170",
    onError: (res: any) => console.log({ res }),
    onSuccess: (res: any) => console.log({ res })
  });

  const handleAuth = () => {
    if(!isReady) return alert('Gateway not ready')
    initAuth({
      displayInAuthError: false,
      displayLoginButtonOnVerification: false
    });
  };

  const handleInvite = () => {
    if(!isReady) return alert('Gateway not ready')
    acceptInvite({
      displayInAuthError: false,
      displayLoginButtonOnVerification: false,
      token: "invite token"
    });
  };

  useEffect(()=>{
    setTimeout(()=>{
      console.log('Test close');
      close()
    }, 6000)
  },[])

  return (
    <>
      <button style={{height:100}} onClick={handleAuth}>Test Auth</button>
      <button style={{height:100}} onClick={handleInvite}>Test Invite</button>
    </>
  );
};

export default App;

useNetAppsSso Hook

The useNetAppsSso hook returns an object with the following properties:

initAuth(options: Object): Function that initializes the authentication flow with NetApp SSO.

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago