@bluedot-innovation/models 7.5.0 → 7.5.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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 7.5.2
2
+ - Set mfaRequired required value to true with (default of false)
3
+
4
+ ## 7.5.1
5
+ - Remove unnecessary validation for screens feature's configuration
6
+
1
7
  ## 7.5.0
2
8
  - Added Hello Configuration to screens feature
3
9
 
@@ -102,18 +102,4 @@ testCase('Account', () => {
102
102
  })
103
103
  })
104
104
  })
105
-
106
- testCase('Configure userToken length', () => {
107
- assertions('should throw error when modifying userToken length with Screens feature disabled', (done) => {
108
- account.features.screens.enabled = false
109
- let Account = new AccountModel(account)
110
-
111
- Account.validate((err, res) => {
112
- assert.notExists(res)
113
- assert.exists(err, 'Screens feature needs to be enabled to modify this configuration')
114
- done()
115
- })
116
- })
117
-
118
- })
119
105
  })
@@ -40,6 +40,19 @@ describe('User', () => {
40
40
  done()
41
41
  })
42
42
  })
43
+
44
+ it('should set mfaRequired to false if not present', (done) => {
45
+ user = JSON.parse(JSON.stringify(user))
46
+ delete user.mfaRequired
47
+
48
+ const User = new UserModel(user)
49
+ assert(User.mfaRequired === false)
50
+ User.validate((err, res) => {
51
+ assert.notExists(res)
52
+ assert(err === null, 'err equals null')
53
+ done()
54
+ })
55
+ })
43
56
  })
44
57
 
45
58
  describe('Invalid User', () => {
@@ -60,6 +73,19 @@ describe('User', () => {
60
73
  })
61
74
  })
62
75
  })
76
+
77
+ it('should not allow mfaRequired to be set to null', (done) => {
78
+ user = JSON.parse(JSON.stringify(user))
79
+ user.mfaRequired = null
80
+ const User = new UserModel(user)
81
+ User.validate((err, res) => {
82
+ assert.notExists(res)
83
+ assert.exists(err, 'err object should exist')
84
+ assert.isObject(err.errors)
85
+ assert.nestedProperty(err, `errors.mfaRequired`, `error should have a mfaRequired property`)
86
+ done()
87
+ })
88
+ })
63
89
  })
64
90
 
65
91
  describe('recursive invalid entry check', () => {
package/models/User.js CHANGED
@@ -41,7 +41,7 @@ let UserSchema = new mongoose.Schema({
41
41
  validator: helpers.validateUUIDv4
42
42
  },
43
43
  superAdmin: Boolean,
44
- mfaRequired: {type: Boolean, default: false},
44
+ mfaRequired: {type: Boolean, default: false, required: true},
45
45
  },
46
46
  {collection: 'user'})
47
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "7.5.0",
3
+ "version": "7.5.2",
4
4
  "main": "Models.js",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",
@@ -7,7 +7,7 @@ function validateScreensFeatureState() {
7
7
 
8
8
  let AccountScreensSchema = new mongoose.Schema({
9
9
  enabled: {type: Boolean},
10
- configuration: {type: HelloConfigurationSchema, validate: {validator: validateScreensFeatureState, msg: 'Screens feature needs to be enabled to modify this configuration'}}
10
+ configuration: HelloConfigurationSchema
11
11
  }, {
12
12
  _id: false
13
13
  })