@modular-rest/server 1.17.1 → 1.18.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.
@@ -10,15 +10,15 @@ 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
12
  permissionGroup: { type: String, required: true },
13
+ type: { type: String, required: true, default: 'user', enum: ['user', 'anonymous'] },
13
14
  email: { type: String, required: false },
14
15
  phone: { type: String, required: false },
15
- password: { type: String, required: true },
16
- type: { type: String, required: true, default: 'user', enum: ['user', 'anonymous'] },
16
+ password: { type: String, required: false },
17
17
  }, { timestamps: true });
18
18
  authSchema.index({ email: 1 }, { unique: true });
19
19
  authSchema.pre(['save', 'updateOne'], function (next) {
20
20
  // Encode the password before saving
21
- if (this.isModified && this.isModified('password')) {
21
+ if (this.isModified && this.isModified('password') && this.password) {
22
22
  this.password = Buffer.from(this.password).toString('base64');
23
23
  }
24
24
  next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-rest/server",
3
- "version": "1.17.1",
3
+ "version": "1.18.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",
@@ -13,10 +13,10 @@ interface AuthDocument extends mongoose.Document {
13
13
  const authSchema = new Schema(
14
14
  {
15
15
  permissionGroup: { type: String, required: true },
16
+ type: { type: String, required: true, default: 'user', enum: ['user', 'anonymous'] },
16
17
  email: { type: String, required: false },
17
18
  phone: { type: String, required: false },
18
- password: { type: String, required: true },
19
- type: { type: String, required: true, default: 'user', enum: ['user', 'anonymous'] },
19
+ password: { type: String, required: false },
20
20
  },
21
21
  { timestamps: true }
22
22
  );
@@ -24,7 +24,7 @@ const authSchema = new Schema(
24
24
  authSchema.index({ email: 1 }, { unique: true });
25
25
  authSchema.pre(['save', 'updateOne'], function (this: AuthDocument, next) {
26
26
  // Encode the password before saving
27
- if (this.isModified && this.isModified('password')) {
27
+ if (this.isModified && this.isModified('password') && this.password) {
28
28
  this.password = Buffer.from(this.password).toString('base64');
29
29
  }
30
30
  next();