@stanlemon/server-with-auth 0.1.0 → 0.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/package.json +4 -4
- package/src/data/simple-users-dao.js +5 -0
- package/src/schema/user.js +1 -1
- package/db.json +0 -21
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stanlemon/server-with-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "A basic express web server setup with authentication baked in.",
|
|
5
5
|
"author": "Stan Lemon <stanlemon@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
8
|
+
"node": ">=16.13.0"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
11
|
"main": "./src/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"lowdb": "^3.0.0",
|
|
25
25
|
"passport": "^0.5.2",
|
|
26
26
|
"passport-jwt": "^4.0.0",
|
|
27
|
-
"shortid": "^2.2.
|
|
27
|
+
"shortid": "^2.2.16",
|
|
28
28
|
"uuid": "^8.3.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -32,4 +32,4 @@
|
|
|
32
32
|
"nodemon": "^2.0.15",
|
|
33
33
|
"supertest": "^6.2.2"
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|
|
@@ -35,6 +35,11 @@ export default class SimpleUsersDao {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
getUserByUsernameAndPassword = (username, password) => {
|
|
38
|
+
// Treat this like a failed login.
|
|
39
|
+
if (!username || !password) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
const user = this.getUserByUsername(username);
|
|
39
44
|
|
|
40
45
|
if (!bcrypt.compareSync(password, user.password)) {
|
package/src/schema/user.js
CHANGED
|
@@ -2,7 +2,7 @@ import Joi from "joi";
|
|
|
2
2
|
|
|
3
3
|
const schema = Joi.object({
|
|
4
4
|
username: Joi.string().required().label("Username"),
|
|
5
|
-
password: Joi.string().required().
|
|
5
|
+
password: Joi.string().required().min(8).max(64).label("Password"),
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
export default schema;
|
package/db.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"users": [
|
|
3
|
-
{
|
|
4
|
-
"username": "user",
|
|
5
|
-
"password": "$2a$10$KBUEk19saDPRLKfJYsI8zOgOYGW7Ms1wLGyAwIISjovUKYlnv2qwi",
|
|
6
|
-
"id": "1e56422f-16a4-4508-a779-6a90d685aca1",
|
|
7
|
-
"verification_token": "nUuif_f3l",
|
|
8
|
-
"created_at": "2022-03-06T18:15:51.821Z",
|
|
9
|
-
"last_updated": "2022-03-06T18:34:07.406Z",
|
|
10
|
-
"last_logged_in": "2022-03-06T18:34:07.405Z"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"username": "test123",
|
|
14
|
-
"password": "$2a$10$G/XayivKQZ6dYmHFJS25G.r/GtEiUIrUh/mJCPu/y7UA56czAogMa",
|
|
15
|
-
"id": "2aa34e59-bc71-4ba0-a6c6-67c565667d84",
|
|
16
|
-
"verification_token": "zk_ZAEWKI",
|
|
17
|
-
"created_at": "2022-03-06T18:17:44.052Z",
|
|
18
|
-
"last_updated": "2022-03-06T18:17:44.052Z"
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|