1.1.20 • Published 3 months ago

my-login-library v1.1.20

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

my-login-library

A professional React library for handling login functionality.

NPM JavaScript Style Guide

Install

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.

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:
// config.js

const authConfig = {
    backendUrl: 'http://your-auth-url',
  };
  
  export default authConfig;
  1. Use the authConfig in your application:
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 :

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 :

    {
     "status": {
       "code": 200,
       "type": "success",
       "msg": "Authentication successful"
     }
    }
  2. In case of wrong credentials :

    {
     "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 ©

1.0.142

3 months ago

1.0.145

3 months ago

1.0.144

3 months ago

1.0.141

3 months ago

1.0.140

3 months ago

1.0.147

3 months ago

1.0.146

3 months ago

1.0.149

3 months ago

1.0.148

3 months ago

1.0.132

3 months ago

1.0.131

3 months ago

1.0.134

3 months ago

1.0.133

3 months ago

1.0.139

3 months ago

1.0.136

3 months ago

1.0.135

3 months ago

1.0.138

3 months ago

1.0.137

3 months ago

1.1.1

3 months ago

1.1.9

3 months ago

1.1.8

3 months ago

1.1.6

3 months ago

1.1.5

3 months ago

1.1.4

3 months ago

1.1.3

3 months ago

1.1.2

3 months ago

1.1.12

3 months ago

1.1.11

3 months ago

1.1.10

3 months ago

1.1.16

3 months ago

1.1.15

3 months ago

1.1.14

3 months ago

1.1.13

3 months ago

1.1.19

3 months ago

1.1.17

3 months ago

1.0.150

3 months ago

1.1.20

3 months ago

1.0.101

3 months ago

1.0.100

3 months ago

1.0.107

3 months ago

1.0.106

3 months ago

1.0.109

3 months ago

1.0.108

3 months ago

1.0.103

3 months ago

1.0.102

3 months ago

1.0.105

3 months ago

1.0.104

3 months ago

1.0.130

3 months ago

1.0.121

3 months ago

1.0.120

3 months ago

1.0.123

3 months ago

1.0.122

3 months ago

1.0.129

3 months ago

1.0.128

3 months ago

1.0.125

3 months ago

1.0.124

3 months ago

1.0.126

3 months ago

1.0.110

3 months ago

1.0.112

3 months ago

1.0.111

3 months ago

1.0.118

3 months ago

1.0.117

3 months ago

1.0.119

3 months ago

1.0.114

3 months ago

1.0.113

3 months ago

1.0.116

3 months ago

1.0.115

3 months ago

1.0.95

3 months ago

1.0.94

3 months ago

1.0.93

3 months ago

1.0.99

3 months ago

1.0.98

3 months ago

1.0.97

3 months ago

1.0.96

3 months ago

1.0.92

3 months ago

1.0.89

4 months ago

1.0.91

4 months ago

1.0.90

4 months ago

1.0.77

4 months ago

1.0.76

4 months ago

1.0.79

4 months ago

1.0.78

4 months ago

1.0.80

4 months ago

1.0.84

4 months ago

1.0.83

4 months ago

1.0.82

4 months ago

1.0.81

4 months ago

1.0.88

4 months ago

1.0.87

4 months ago

1.0.86

4 months ago

1.0.85

4 months ago

1.0.75

4 months ago

1.0.74

4 months ago

1.0.39

5 months ago

1.0.38

5 months ago

1.0.26

5 months ago

1.0.29

5 months ago

1.0.27

5 months ago

1.0.33

5 months ago

1.0.32

5 months ago

1.0.31

5 months ago

1.0.30

5 months ago

1.0.37

5 months ago

1.0.36

5 months ago

1.0.35

5 months ago

1.0.34

5 months ago

1.0.25

5 months ago

1.0.24

5 months ago

1.0.23

5 months ago

1.0.22

5 months ago

1.0.21

5 months ago

1.0.19

5 months ago

1.0.18

5 months ago

1.0.17

5 months ago

1.0.16

5 months ago

1.0.15

5 months ago

1.0.14

5 months ago

1.0.13

5 months ago

1.0.12

5 months ago

1.0.11

5 months ago

1.0.10

5 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago