1.1.4 • Published 3 years ago

sbx-react-auth-hoc v1.1.4

Weekly downloads
17
License
MIT
Repository
-
Last release
3 years ago

sbx-react-auth-hoc

Authentication wrapper library for sbx

NPM JavaScript Style Guide

Install

npm install --save sbx-react-auth-hoc
yarn add sbx-react-auth-h oc

Usage

import React, {useState} from "react";
import { initialize, Auth } from "sbx-react-auth-hoc";
import { SbxCoreService, SbxSessionService } from "sbx-axios";

const sbxCoreService = new SbxCoreService();
const sbxSessionService = new SbxSessionService(sbxCoreService);
sbxSessionService.initialize(process.env.REACT_APP_DOMAIN, process.env.REACT_APP_APP_KEY);

initialize(sbxCoreService, sbxSessionService, process.env.REACT_APP_VALIDATE_CS);

const App = () => {
  const [logged, setLogged] = useState(false);

  function handleLogin() {
    setLogged(true);
  }

  return (
    <div>
      <Auth
        onError={() => {
          console.log("not ok");
        }}
        onSuccess={res => {
          console.log(res);
          setLogged(true);
        }}
        onErrorComponent={<div>not ok</div>}
        logged={logged}
      >
        <div>ok</div>
      </Auth>

      <button onClick={handleLogin}>login</button>
    </div>
  );
};

export default App;

License

MIT © caberrio

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

4 years ago

1.0.6

4 years ago

1.1.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago