authbackendpackage 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
---
|
|
3
|
+
|
|
1
4
|
# 🔐 AuthBackendPackage
|
|
2
5
|
|
|
3
|
-
A flexible and plug-and-play authentication module for Node.js applications. Provides features such as OTP-based verification, JWT authentication, email verification, password reset, and user profile management.
|
|
6
|
+
A flexible and plug-and-play authentication module for [Node.js](w) applications. Provides features such as [OTP](w)-based verification, [JWT](w) authentication, email verification, password reset, and user profile management.
|
|
7
|
+
|
|
8
|
+
✅ **Successfully tested and used in production at:**
|
|
9
|
+
🔗 [https://pulsetalk-6lrk.onrender.com](https://pulsetalk-6lrk.onrender.com)
|
|
4
10
|
|
|
5
11
|
---
|
|
6
12
|
|
|
@@ -37,10 +43,7 @@ const auth = createAuthModule({
|
|
|
37
43
|
|
|
38
44
|
## ☁️ Cloudinary Configuration
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
Then, create an API key and place the values in your `.env` file.
|
|
42
|
-
|
|
43
|
-
Cloudinary is used for storing profile or other images.
|
|
46
|
+
Create an account on [Cloudinary](https://cloudinary.com/), generate API credentials, and store them in your `.env` file.
|
|
44
47
|
|
|
45
48
|
**Cloudinary Instance:**
|
|
46
49
|
|
|
@@ -62,11 +65,15 @@ export default cloudinary;
|
|
|
62
65
|
|
|
63
66
|
## 🔐 JWT Secret
|
|
64
67
|
|
|
65
|
-
|
|
68
|
+
Set a secure `JWT_SECRET` string in your `.env` file.
|
|
69
|
+
|
|
70
|
+
---
|
|
66
71
|
|
|
67
72
|
## 📧 Mail Setup
|
|
68
73
|
|
|
69
|
-
Generate an **App Password**
|
|
74
|
+
Generate an **App Password** from your Gmail settings and store it in `.env`.
|
|
75
|
+
|
|
76
|
+
👉 Follow this [Gmail App Password Guide](https://itsupport.umd.edu/itsupport?id=kb_article_view&sysparm_article=KB0015112)
|
|
70
77
|
|
|
71
78
|
---
|
|
72
79
|
|
|
@@ -76,23 +83,10 @@ Generate an **App Password** using your Gmail account. Refer to this [guide](htt
|
|
|
76
83
|
import mongoose from 'mongoose';
|
|
77
84
|
|
|
78
85
|
const userSchema = new mongoose.Schema({
|
|
79
|
-
email: {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
name: {
|
|
85
|
-
type: String,
|
|
86
|
-
required: true,
|
|
87
|
-
},
|
|
88
|
-
password: {
|
|
89
|
-
type: String,
|
|
90
|
-
required: true,
|
|
91
|
-
},
|
|
92
|
-
profilePicture: {
|
|
93
|
-
type: String,
|
|
94
|
-
default: "",
|
|
95
|
-
},
|
|
86
|
+
email: { type: String, required: true, unique: true },
|
|
87
|
+
name: { type: String, required: true },
|
|
88
|
+
password: { type: String, required: true },
|
|
89
|
+
profilePicture: { type: String, default: "" },
|
|
96
90
|
}, { timestamps: true });
|
|
97
91
|
|
|
98
92
|
const User = mongoose.model('User', userSchema);
|
|
@@ -151,13 +145,13 @@ export const protectRoute = async (req, res, next) => {
|
|
|
151
145
|
|
|
152
146
|
## 🧠 Features
|
|
153
147
|
|
|
154
|
-
* ✅ OTP verification via email (SMTP
|
|
148
|
+
* ✅ OTP verification via email (SMTP)
|
|
155
149
|
* ✅ Signup with verified OTP
|
|
156
150
|
* ✅ Secure login with JWT
|
|
157
|
-
* ✅ Profile update with
|
|
158
|
-
* ✅ Forgot password with bcrypt
|
|
159
|
-
* ✅
|
|
160
|
-
* ✅ Middleware-ready
|
|
151
|
+
* ✅ Profile update with image support (Cloudinary)
|
|
152
|
+
* ✅ Forgot password with [bcrypt](w)
|
|
153
|
+
* ✅ Cookie-based logout
|
|
154
|
+
* ✅ Middleware-ready routes
|
|
161
155
|
|
|
162
156
|
---
|
|
163
157
|
|
|
@@ -165,9 +159,12 @@ export const protectRoute = async (req, res, next) => {
|
|
|
165
159
|
|
|
166
160
|
```env
|
|
167
161
|
MY_MAIL=your-email@gmail.com
|
|
168
|
-
MY_PASSWORD=your-
|
|
162
|
+
MY_PASSWORD=your-app-password
|
|
169
163
|
JWT_SECRET=your-secret-key
|
|
170
164
|
NODE_ENV=development
|
|
165
|
+
CLOUDINARY_CLOUD_NAME=your-cloud-name
|
|
166
|
+
CLOUDINARY_API_KEY=your-api-key
|
|
167
|
+
CLOUDINARY_API_SECRET=your-api-secret
|
|
171
168
|
```
|
|
172
169
|
|
|
173
170
|
---
|
|
@@ -244,14 +241,23 @@ Content-Type: application/json
|
|
|
244
241
|
|
|
245
242
|
## 🔐 Cookie-Based JWT Auth
|
|
246
243
|
|
|
247
|
-
|
|
244
|
+
Authentication is done using `httpOnly` cookies which automatically expire after 7 days for enhanced security.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## 🚀 Live Usage Demo
|
|
249
|
+
|
|
250
|
+
✅ **Successfully running on:**
|
|
251
|
+
🌐 [https://pulsetalk-6lrk.onrender.com](https://pulsetalk-6lrk.onrender.com)
|
|
248
252
|
|
|
249
253
|
---
|
|
250
254
|
|
|
251
255
|
## 📄 License
|
|
252
256
|
|
|
253
|
-
Apache-2.0
|
|
257
|
+
Licensed under [Apache-2.0](w).
|
|
254
258
|
|
|
255
259
|
---
|
|
256
260
|
|
|
257
|
-
Built with ❤️ by the Shreyash Team
|
|
261
|
+
Built with ❤️ by the **Shreyash Team**
|
|
262
|
+
|
|
263
|
+
---
|