1.0.73 • Published 5 months ago

pwc-login-library v1.0.73

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

login-library

A professional React library for handling login functionality.

NPM JavaScript Style Guide

Install

npm install --save login-library

Usage

This is a basic login form which can be triggered upon calling {LoginForm} from the library and can be used for authentication purpose by user given configurable gateways and api endpoints. This is an example of implementing the library in a basic app.

import { LoginForm } from 'login-library';

const App = () => {
  return (
    <div>
      <h1>Welcome to My App</h1>
      <LoginForm onLogin={(username) => console.log(`Logged in as ${username}`)} />
    </div>
  );
};

export default App;

Configuration

The library accepts a configuration object as a prop. You can customize the behavior by passing a config prop to the LoginForm component:

  1. Create a config.js file in the root of your project:
// config.js

const authConfig = {
    gatewayConfig: 'microservice',
    microserviceApiUrl: 'http://your-auth-url',
    // Add any other required microservice-specific configurations...
  };
  
  export default authConfig;
  1. Use the authConfig in your application:
import { LoginForm } from 'login-library';
import authConfig from './config'; // Adjust the path based on your project structure

const App = () => {
  const handleLogin = (username) => {
    console.log(`Logged in as ${username}`);
    // Add your logic for handling successful login
    // For example, navigate to another page, fetch user data, etc.
    // You can also trigger other side effects or actions here.
  };

  return (
    <div>
      <h1>Welcome to My App</h1>
      <LoginForm onLogin={handleLogin} config={authConfig} />
    </div>
  );
};

export default App;

Expected Outcome

Successful Login:

  • Upon successful login, the handleLogin function is called.
  • You should see a log message indicating the successful login.
  • Customize the handleLogin function to perform actions such as navigation to another page, fetching user data, etc.

Pre-Requesites

User needs to have an API running for a database which contains username and password.

Future Plans

  • JWT and Azure Ad based authentication

License

MIT ©

1.0.62

5 months ago

1.0.61

5 months ago

1.0.60

5 months ago

1.0.66

5 months ago

1.0.65

5 months ago

1.0.64

5 months ago

1.0.63

5 months ago

1.0.69

5 months ago

1.0.68

5 months ago

1.0.67

5 months ago

1.0.73

5 months ago

1.0.72

5 months ago

1.0.71

5 months ago

1.0.70

5 months ago

1.0.59

5 months ago

1.0.58

5 months ago

1.0.57

5 months ago

1.0.56

5 months ago

1.0.55

5 months ago

1.0.54

5 months ago

1.0.53

5 months ago

1.0.52

5 months ago

1.0.49

5 months ago

1.0.51

5 months ago

1.0.50

5 months ago

1.0.48

5 months ago

1.0.47

5 months ago

1.0.46

5 months ago

1.0.45

5 months ago

1.0.44

5 months ago

1.0.43

5 months ago

1.0.42

5 months ago

1.0.41

5 months ago