# my-login-library

> Made with create-react-library

Latest version **1.1.20** (published 2024-01-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install my-login-library
pnpm add my-login-library
yarn add my-login-library
bun add my-login-library
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.20 |
| Published | 2024-01-31 |
| First published | 2023-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 4 |
| Unpacked size | 167.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Abhijeet Raj |
| Maintainers | abhijeetraj1002 |

## Links

- npm: https://www.npmjs.com/package/my-login-library
- Repository: /my-login-library
- npm.io page: https://npm.io/package/my-login-library

## Dependencies (4)

- [msal](https://npm.io/package/msal.md) ^1.4.18
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^9.0.2
- [@azure/msal-react](https://npm.io/package/@azure/msal-react.md) ^2.0.8
- [@azure/msal-browser](https://npm.io/package/@azure/msal-browser.md) ^3.6.0

## Recent versions

- 1.1.20 (latest) — 2024-01-31
- 1.1.19 — 2024-01-31
- 1.1.17 — 2024-01-31
- 1.1.16 — 2024-01-31
- 1.1.15 — 2024-01-31
- 1.1.14 — 2024-01-31
- 1.1.13 — 2024-01-31
- 1.1.12 — 2024-01-31
- 1.1.11 — 2024-01-31
- 1.1.10 — 2024-01-31
- 1.1.9 — 2024-01-31
- 1.1.8 — 2024-01-31
- 1.1.6 — 2024-01-31
- 1.1.5 — 2024-01-31
- 1.1.4 — 2024-01-31
- … 116 more at https://npm.io/package/my-login-library/versions

## README

# my-login-library

> A professional React library for handling login functionality.

[![NPM](https://img.shields.io/npm/v/@et/pwc-login-library.svg)](https://www.npmjs.com/package/@et/pwc-login-library) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install my-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 microservice api endpoints. This is an example of implementing the library in a basic app.

```jsx
import { LoginForm } from 'my-login-library';

const App = () => {
  return (
    <div>
      <LoginForm/>
    </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:

```jsx
// config.js

const authConfig = {
    backendUrl: 'http://your-auth-url',
  };
  
  export default authConfig;

```

2. Use the authConfig in your application:

```jsx
import React from 'react';
import { LoginForm } from 'my-login-library';
import authConfig from './config'; 

const App = () => {
  
    // Destructure configurations from the imported authConfig object
    const { backendUrl } = authConfig;
  
    // Handle login callback
    const handleLogin = () => {
      // Perform any actions upon successful login
    };
  
    return (
      <LoginForm
        onLogin={handleLogin}
        backendUrl={backendUrl}
        
      />
    );
  };
  
  export default App;

```


## Expected Input

Now on the basis of the ApiUrl from the config file the user must have a backend which has two fields username and password and must have a POST method for authentication. The post method should call the backend api from the url mentioned in the config file "http://your-auth-url" with a "/authenticate" endpoint. The Service Response should somewhat look like this :

```bash
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"username": "your_username", "password": "your_password", "appName": "your_appname"}' \
  http://your-api-base-url/authenticate

```


## 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.
 
 1. The response of a succesfull login is :

 ```json
 {
  "status": {
    "code": 200,
    "type": "success",
    "msg": "Authentication successful"
  }
}

 ```

 2. In case of wrong credentials :

 ```json
{
  "status": {
    "code": 401,
    "type": "failure",
    "msg": "password mismatch"
  }
}

```

3. In case where the server cannot or will not process the request due to something that is perceived to be a client error:

 ```json
{
  "status": {
    "code": 404,
    "type": "failure",
    "msg": "Not Found"
  }
}

```

When user fills the correct credentials they will get a Login Successful message and then as per the handle login function other tasks will be performed.


## Pre-Requesites

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

## Future Plans

- JWT and Azure Ad based authentication 


## License

MIT © [](https://github.com/)

---
_Source: https://npm.io/package/my-login-library · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
