@modular-rest/server 1.15.0 → 1.16.1
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/dist/class/user.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare class User {
|
|
|
37
37
|
*
|
|
38
38
|
* @hidden
|
|
39
39
|
*/
|
|
40
|
-
constructor(id: string, permissionGroup: string, phone: string, email: string, password: string, type:
|
|
40
|
+
constructor(id: string, permissionGroup: string, phone: string, email: string, password: string, type: 'user' | 'anonymous', model: any);
|
|
41
41
|
/**
|
|
42
42
|
* Get brief user information
|
|
43
43
|
* @returns Brief user info object
|
|
@@ -9,11 +9,11 @@ const security_1 = require("../../class/security");
|
|
|
9
9
|
const config_1 = require("../../config");
|
|
10
10
|
const trigger_operator_1 = __importDefault(require("../../class/trigger_operator"));
|
|
11
11
|
const authSchema = new mongoose_1.Schema({
|
|
12
|
-
permissionGroup: String,
|
|
13
|
-
email: String,
|
|
14
|
-
phone: String,
|
|
15
|
-
password: String,
|
|
16
|
-
type: { type: String, default: 'user', enum: ['user', 'anonymous'] },
|
|
12
|
+
permissionGroup: { type: String, required: true },
|
|
13
|
+
email: { type: String, required: false },
|
|
14
|
+
phone: { type: String, required: false },
|
|
15
|
+
password: { type: String, required: true },
|
|
16
|
+
type: { type: String, required: true, default: 'user', enum: ['user', 'anonymous'] },
|
|
17
17
|
}, { timestamps: true });
|
|
18
18
|
authSchema.index({ email: 1 }, { unique: true });
|
|
19
19
|
authSchema.pre(['save', 'updateOne'], function (next) {
|
|
@@ -451,7 +451,7 @@ class UserManager {
|
|
|
451
451
|
// Load user
|
|
452
452
|
const user = await user_1.User.loadFromModel(gottenFromDB);
|
|
453
453
|
// Update password
|
|
454
|
-
user.password =
|
|
454
|
+
user.password = password;
|
|
455
455
|
// Save to database
|
|
456
456
|
await user.save();
|
|
457
457
|
// Get token payload
|
|
@@ -513,7 +513,7 @@ class UserManager {
|
|
|
513
513
|
// Load user
|
|
514
514
|
const user = await user_1.User.loadFromModel(gottenFromDB);
|
|
515
515
|
// Update password
|
|
516
|
-
user.password =
|
|
516
|
+
user.password = password;
|
|
517
517
|
// Save to database
|
|
518
518
|
await user.save();
|
|
519
519
|
// Get token payload
|
|
@@ -562,9 +562,9 @@ class UserManager {
|
|
|
562
562
|
...detail,
|
|
563
563
|
type: detail.type || 'user',
|
|
564
564
|
permissionGroup: detail.permissionGroup || (0, permissionManager_1.getDefaultPermissionGroups)().title,
|
|
565
|
-
phone: detail.phone ||
|
|
566
|
-
email: detail.email ||
|
|
567
|
-
password: detail.password
|
|
565
|
+
phone: detail.phone || undefined,
|
|
566
|
+
email: detail.email || undefined,
|
|
567
|
+
password: detail.password || undefined,
|
|
568
568
|
});
|
|
569
569
|
// Load user from document
|
|
570
570
|
const user = await user_1.User.loadFromModel(userDoc);
|
|
@@ -610,7 +610,7 @@ class UserManager {
|
|
|
610
610
|
throw new Error('User not found');
|
|
611
611
|
}
|
|
612
612
|
const user = await user_1.User.loadFromModel(userDoc);
|
|
613
|
-
user.password =
|
|
613
|
+
user.password = newPass;
|
|
614
614
|
await user.save();
|
|
615
615
|
}
|
|
616
616
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modular-rest/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "TypeScript version of a nodejs module based on KOAJS for developing Rest-APIs in a modular solution.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"bugs": {
|
|
28
28
|
"url": "https://github.com/modular-rest/modular-rest/issues"
|
|
29
29
|
},
|
|
30
|
-
"homepage": "https://
|
|
30
|
+
"homepage": "https://modular-rest.github.io/modular-rest",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@koa/cors": "^3.1.0",
|
|
33
33
|
"colog": "^1.0.4",
|
package/src/class/user.ts
CHANGED
|
@@ -12,11 +12,11 @@ interface AuthDocument extends mongoose.Document {
|
|
|
12
12
|
|
|
13
13
|
const authSchema = new Schema(
|
|
14
14
|
{
|
|
15
|
-
permissionGroup: String,
|
|
16
|
-
email: String,
|
|
17
|
-
phone: String,
|
|
18
|
-
password: String,
|
|
19
|
-
type: { type: String, default: 'user', enum: ['user', 'anonymous'] },
|
|
15
|
+
permissionGroup: { type: String, required: true },
|
|
16
|
+
email: { type: String, required: false },
|
|
17
|
+
phone: { type: String, required: false },
|
|
18
|
+
password: { type: String, required: true },
|
|
19
|
+
type: { type: String, required: true, default: 'user', enum: ['user', 'anonymous'] },
|
|
20
20
|
},
|
|
21
21
|
{ timestamps: true }
|
|
22
22
|
);
|
|
@@ -495,7 +495,7 @@ class UserManager {
|
|
|
495
495
|
const user = await User.loadFromModel(gottenFromDB);
|
|
496
496
|
|
|
497
497
|
// Update password
|
|
498
|
-
user.password =
|
|
498
|
+
user.password = password;
|
|
499
499
|
|
|
500
500
|
// Save to database
|
|
501
501
|
await user.save();
|
|
@@ -568,7 +568,7 @@ class UserManager {
|
|
|
568
568
|
const user = await User.loadFromModel(gottenFromDB);
|
|
569
569
|
|
|
570
570
|
// Update password
|
|
571
|
-
user.password =
|
|
571
|
+
user.password = password;
|
|
572
572
|
|
|
573
573
|
// Save to database
|
|
574
574
|
await user.save();
|
|
@@ -624,9 +624,9 @@ class UserManager {
|
|
|
624
624
|
...detail,
|
|
625
625
|
type: detail.type || 'user',
|
|
626
626
|
permissionGroup: detail.permissionGroup || getDefaultPermissionGroups().title,
|
|
627
|
-
phone: detail.phone ||
|
|
628
|
-
email: detail.email ||
|
|
629
|
-
password: detail.password
|
|
627
|
+
phone: detail.phone || undefined,
|
|
628
|
+
email: detail.email || undefined,
|
|
629
|
+
password: detail.password || undefined,
|
|
630
630
|
});
|
|
631
631
|
|
|
632
632
|
// Load user from document
|
|
@@ -679,7 +679,7 @@ class UserManager {
|
|
|
679
679
|
}
|
|
680
680
|
|
|
681
681
|
const user = await User.loadFromModel(userDoc);
|
|
682
|
-
user.password =
|
|
682
|
+
user.password = newPass;
|
|
683
683
|
await user.save();
|
|
684
684
|
}
|
|
685
685
|
|