authbackendpackage 1.1.1 β 1.1.2
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 +40 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
Hereβs the updated **README** file with the mention of successful testing on your website **PulseTalk**:
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
1
5
|
# π AuthBackendPackage
|
|
2
6
|
|
|
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.
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
β
**Successfully tested and used in production at:**
|
|
10
|
+
π [https://pulsetalk-6lrk.onrender.com](https://pulsetalk-6lrk.onrender.com)
|
|
4
11
|
|
|
5
12
|
---
|
|
6
13
|
|
|
@@ -37,10 +44,7 @@ const auth = createAuthModule({
|
|
|
37
44
|
|
|
38
45
|
## βοΈ Cloudinary Configuration
|
|
39
46
|
|
|
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.
|
|
47
|
+
Create an account on [Cloudinary](https://cloudinary.com/), generate API credentials, and store them in your `.env` file.
|
|
44
48
|
|
|
45
49
|
**Cloudinary Instance:**
|
|
46
50
|
|
|
@@ -62,11 +66,15 @@ export default cloudinary;
|
|
|
62
66
|
|
|
63
67
|
## π JWT Secret
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
Set a secure `JWT_SECRET` string in your `.env` file.
|
|
70
|
+
|
|
71
|
+
---
|
|
66
72
|
|
|
67
73
|
## π§ Mail Setup
|
|
68
74
|
|
|
69
|
-
Generate an **App Password**
|
|
75
|
+
Generate an **App Password** from your Gmail settings and store it in `.env`.
|
|
76
|
+
|
|
77
|
+
π Follow this [Gmail App Password Guide](https://itsupport.umd.edu/itsupport?id=kb_article_view&sysparm_article=KB0015112)
|
|
70
78
|
|
|
71
79
|
---
|
|
72
80
|
|
|
@@ -76,23 +84,10 @@ Generate an **App Password** using your Gmail account. Refer to this [guide](htt
|
|
|
76
84
|
import mongoose from 'mongoose';
|
|
77
85
|
|
|
78
86
|
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
|
-
},
|
|
87
|
+
email: { type: String, required: true, unique: true },
|
|
88
|
+
name: { type: String, required: true },
|
|
89
|
+
password: { type: String, required: true },
|
|
90
|
+
profilePicture: { type: String, default: "" },
|
|
96
91
|
}, { timestamps: true });
|
|
97
92
|
|
|
98
93
|
const User = mongoose.model('User', userSchema);
|
|
@@ -151,13 +146,13 @@ export const protectRoute = async (req, res, next) => {
|
|
|
151
146
|
|
|
152
147
|
## π§ Features
|
|
153
148
|
|
|
154
|
-
* β
OTP verification via email (SMTP
|
|
149
|
+
* β
OTP verification via email (SMTP)
|
|
155
150
|
* β
Signup with verified OTP
|
|
156
151
|
* β
Secure login with JWT
|
|
157
|
-
* β
Profile update with
|
|
158
|
-
* β
Forgot password with bcrypt
|
|
159
|
-
* β
|
|
160
|
-
* β
Middleware-ready
|
|
152
|
+
* β
Profile update with image support (Cloudinary)
|
|
153
|
+
* β
Forgot password with [bcrypt](w)
|
|
154
|
+
* β
Cookie-based logout
|
|
155
|
+
* β
Middleware-ready routes
|
|
161
156
|
|
|
162
157
|
---
|
|
163
158
|
|
|
@@ -165,9 +160,12 @@ export const protectRoute = async (req, res, next) => {
|
|
|
165
160
|
|
|
166
161
|
```env
|
|
167
162
|
MY_MAIL=your-email@gmail.com
|
|
168
|
-
MY_PASSWORD=your-
|
|
163
|
+
MY_PASSWORD=your-app-password
|
|
169
164
|
JWT_SECRET=your-secret-key
|
|
170
165
|
NODE_ENV=development
|
|
166
|
+
CLOUDINARY_CLOUD_NAME=your-cloud-name
|
|
167
|
+
CLOUDINARY_API_KEY=your-api-key
|
|
168
|
+
CLOUDINARY_API_SECRET=your-api-secret
|
|
171
169
|
```
|
|
172
170
|
|
|
173
171
|
---
|
|
@@ -244,14 +242,23 @@ Content-Type: application/json
|
|
|
244
242
|
|
|
245
243
|
## π Cookie-Based JWT Auth
|
|
246
244
|
|
|
247
|
-
|
|
245
|
+
Authentication is done using `httpOnly` cookies which automatically expire after 7 days for enhanced security.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## π Live Usage Demo
|
|
250
|
+
|
|
251
|
+
β
**Successfully running on:**
|
|
252
|
+
π [https://pulsetalk-6lrk.onrender.com](https://pulsetalk-6lrk.onrender.com)
|
|
248
253
|
|
|
249
254
|
---
|
|
250
255
|
|
|
251
256
|
## π License
|
|
252
257
|
|
|
253
|
-
Apache-2.0
|
|
258
|
+
Licensed under [Apache-2.0](w).
|
|
254
259
|
|
|
255
260
|
---
|
|
256
261
|
|
|
257
|
-
Built with β€οΈ by the Shreyash Team
|
|
262
|
+
Built with β€οΈ by the **Shreyash Team**
|
|
263
|
+
|
|
264
|
+
---
|