Installations
npm install complete-auth
Developer Guide
Typescript
No
Module System
ESM
Node Version
20.17.0
NPM Version
10.8.2
Score
50.3
Supply Chain
84.7
Quality
76.8
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Total Downloads
Cumulative downloads
Total Downloads
334
Last day
200%
3
Compared to previous day
Last week
27.3%
14
Compared to previous week
Last month
39.4%
46
Compared to previous month
Last year
0%
334
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
16
Complete Auth
Developer: PRAMOD THYAGARAJ
Connect
An easy-to-use module for handling user and admin authentication via email OTP. This module supports login and signup flows for both users and admins, providing a robust and secure way to manage authentication in your application.
Features
Login
-
Login as User:
- Users can log in using their email and a One-Time Password (OTP) sent to their email.
-
Login as Admin:
- Admins can log in using their email and a One-Time Password (OTP) sent to their email.
Signup
-
Signup as User:
- Users can sign up by entering their email and receiving an OTP to verify their account.
-
Signup as Admin:
- Admins can sign up by entering their email. An OTP will be sent to the super admin's email for verification before the account is created.
Setup Guide
Prerequisites
- Node.js: Ensure you have Node.js installed (>= 14.x recommended).
- npm: Ensure npm is available for managing dependencies.
Step 1: Install the Package
Install the complete-auth
package via npm:
1npm install complete-auth
Step 2: Create a .env
File
In the root directory of your project, create a .env
file to configure the backend API endpoint:
1VITE_BACKEND_ENDPOINT=http://localhost:8000/api
- Replace
http://localhost:8000/api
with your actual backend API URL.
Step 3: Usage Guide
1. Import and Initialize the Module
Import the module into your application and initialize it.
1import { login, signup } from "authentication-module";
2. Login Functions
Login as User
1login("user", { 2 email: "user@example.com", 3 otp: "123456", // OTP sent to the user's email 4}) 5 .then((response) => console.log("Login successful:", response)) 6 .catch((error) => console.error("Login failed:", error));
Login as Admin
1login("admin", { 2 email: "admin@example.com", 3 otp: "123456", // OTP sent to the admin's email 4}) 5 .then((response) => console.log("Admin login successful:", response)) 6 .catch((error) => console.error("Admin login failed:", error));
3. Signup Functions
Signup as User
1signup("user", { 2 email: "user@example.com", 3}) 4 .then((response) => console.log("Signup successful:", response)) 5 .catch((error) => console.error("Signup failed:", error));
Signup as Admin
1signup("admin", { 2 email: "admin@example.com", 3}) 4 .then((response) => console.log("Admin signup request sent:", response)) 5 .catch((error) => console.error("Admin signup failed:", error));
Step 4: Backend API Setup
Ensure the backend API supports the following endpoints:
Endpoints
- POST
/user/login
:- Handles user and admin login with email OTP.
- POST
/user/signup
:- Handles user signup and sends OTP to the user's email.
- POST
user/signup/admin
:- Sends an OTP to the super admin for admin account creation.
Environment Variables
Variable | Description | Example |
---|---|---|
VITE_BACKEND_ENDPOINT | Backend API base URL | http://localhost:8000/api |
Key Features
- Easy Integration:
- Simplifies OTP-based login and signup processes for users and admins.
- Secure:
- Ensures account verification through OTP mechanisms.
- Customizable:
- Supports environment-based configuration for different backend endpoints.
Troubleshooting
-
"Module not found" Error:
- Ensure the package is installed correctly using
npm install complete-auth
.
- Ensure the package is installed correctly using
-
Backend Not Responding:
- Verify the
VITE_BACKEND_ENDPOINT
in the.env
file is pointing to a valid backend API.
- Verify the
-
Login/Signup Fails:
- Ensure the backend API is running and properly configured to handle the respective endpoints.
Happy authenticating! 🎉
No vulnerabilities found.
No security vulnerabilities found.
Other packages similar to complete-auth
@invertase/react-native-apple-authentication
A complete Apple Authentication services API for React Native iOS apps.
@heymarco/next-auth
A complete authentication solution for web applications.
redux-auth
Complete token authentication system for react + redux.
auth-module-lsgb
this package is used for complete authentication and authorization