crazy-odds-bet-shared 1.0.28 → 1.0.30
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/models/betTracker.js +1 -0
- package/models/index.js +4 -4
- package/models/user.js +4 -5
- package/models/userPermission.js +21 -0
- package/models/userRole.js +21 -0
- package/package.json +1 -1
- package/models/permission.js +0 -21
- package/models/role.js +0 -21
package/models/betTracker.js
CHANGED
|
@@ -4,6 +4,7 @@ const { createBaseSchema, baseSchemaOptions } = require('./base');
|
|
|
4
4
|
const betTrackerSchema = new Schema(
|
|
5
5
|
{
|
|
6
6
|
...createBaseSchema(),
|
|
7
|
+
userId: { type: String, ref: 'User' },
|
|
7
8
|
groupId: { type: String },
|
|
8
9
|
bookmaker: { type: Object, properties: {
|
|
9
10
|
id: { type: String, required: true, ref: 'Bookmaker' },
|
package/models/index.js
CHANGED
|
@@ -6,8 +6,8 @@ const { Team } = require('./team');
|
|
|
6
6
|
const { Player } = require('./player');
|
|
7
7
|
const { Fixture, FixtureStatus } = require('./fixture');
|
|
8
8
|
const { User } = require('./user');
|
|
9
|
-
const {
|
|
10
|
-
const {
|
|
9
|
+
const { UserPermission } = require('./userPermission');
|
|
10
|
+
const { UserRole } = require('./userRole');
|
|
11
11
|
const { MarketTemplate } = require('./marketTemplate');
|
|
12
12
|
const { Market } = require('./market');
|
|
13
13
|
const { Odd } = require('./odd');
|
|
@@ -25,8 +25,8 @@ module.exports = {
|
|
|
25
25
|
Fixture,
|
|
26
26
|
FixtureStatus,
|
|
27
27
|
User,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
UserPermission,
|
|
29
|
+
UserRole,
|
|
30
30
|
MarketTemplate,
|
|
31
31
|
Market,
|
|
32
32
|
Odd,
|
package/models/user.js
CHANGED
|
@@ -14,9 +14,8 @@ const userSchema = new Schema(
|
|
|
14
14
|
email: { type: String, required: true, unique: true, lowercase: true, trim: true },
|
|
15
15
|
password: { type: String, required: true },
|
|
16
16
|
name: { type: String, required: true },
|
|
17
|
-
roleId: { type: String, ref: '
|
|
18
|
-
|
|
19
|
-
permissionIds: [{ type: String, ref: 'Permission' }],
|
|
17
|
+
roleId: { type: String, ref: 'UserRole', default: null },
|
|
18
|
+
permissionIds: [{ type: String, ref: 'UserPermission' }],
|
|
20
19
|
config: { type: Schema.Types.Mixed, default: {} },
|
|
21
20
|
isActive: { type: Boolean, default: true }
|
|
22
21
|
},
|
|
@@ -51,8 +50,8 @@ userSchema.static('getActive', function () {
|
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
userSchema.static('findAdmins', async function () {
|
|
54
|
-
const
|
|
55
|
-
const adminRole = await
|
|
53
|
+
const UserRole = this.db.model('UserRole');
|
|
54
|
+
const adminRole = await UserRole.findOne({ name: 'Admin' }).lean();
|
|
56
55
|
if (!adminRole) return this.find({ _id: { $in: [] } }).select('-password');
|
|
57
56
|
return this.find({ roleId: adminRole._id, isActive: true }).select('-password');
|
|
58
57
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { Schema, model } = require('mongoose');
|
|
2
|
+
const { createBaseSchema, baseSchemaOptions } = require('./base');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* UserPermission schema - granular permission codes (e.g. "users:read", "roles:write")
|
|
6
|
+
*/
|
|
7
|
+
const userPermissionSchema = new Schema(
|
|
8
|
+
{
|
|
9
|
+
...createBaseSchema(),
|
|
10
|
+
code: { type: String, required: true, unique: true, trim: true },
|
|
11
|
+
name: { type: String, required: true, trim: true },
|
|
12
|
+
description: { type: String, default: '' }
|
|
13
|
+
},
|
|
14
|
+
{ ...baseSchemaOptions, collection: 'userpermissions' }
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
userPermissionSchema.index({ code: 1 });
|
|
18
|
+
|
|
19
|
+
const UserPermission = model('UserPermission', userPermissionSchema);
|
|
20
|
+
|
|
21
|
+
module.exports = { UserPermission };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { Schema, model } = require('mongoose');
|
|
2
|
+
const { createBaseSchema, baseSchemaOptions } = require('./base');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* UserRole schema - named roles with a set of permission IDs (inherited by users assigned this role)
|
|
6
|
+
*/
|
|
7
|
+
const userRoleSchema = new Schema(
|
|
8
|
+
{
|
|
9
|
+
...createBaseSchema(),
|
|
10
|
+
name: { type: String, required: true, unique: true, trim: true },
|
|
11
|
+
description: { type: String, default: '' },
|
|
12
|
+
permissionIds: [{ type: String, ref: 'UserPermission' }]
|
|
13
|
+
},
|
|
14
|
+
{ ...baseSchemaOptions, collection: 'userroles' }
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
userRoleSchema.index({ name: 1 });
|
|
18
|
+
|
|
19
|
+
const UserRole = model('UserRole', userRoleSchema);
|
|
20
|
+
|
|
21
|
+
module.exports = { UserRole };
|
package/package.json
CHANGED
package/models/permission.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const { Schema, model } = require('mongoose');
|
|
2
|
-
const { createBaseSchema, baseSchemaOptions } = require('./base');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Permission schema - granular permission codes (e.g. "users:read", "roles:write")
|
|
6
|
-
*/
|
|
7
|
-
const permissionSchema = new Schema(
|
|
8
|
-
{
|
|
9
|
-
...createBaseSchema(),
|
|
10
|
-
code: { type: String, required: true, unique: true, trim: true },
|
|
11
|
-
name: { type: String, required: true, trim: true },
|
|
12
|
-
description: { type: String, default: '' }
|
|
13
|
-
},
|
|
14
|
-
baseSchemaOptions
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
permissionSchema.index({ code: 1 });
|
|
18
|
-
|
|
19
|
-
const Permission = model('Permission', permissionSchema);
|
|
20
|
-
|
|
21
|
-
module.exports = { Permission };
|
package/models/role.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const { Schema, model } = require('mongoose');
|
|
2
|
-
const { createBaseSchema, baseSchemaOptions } = require('./base');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Role schema - named roles with a set of permission IDs (inherited by users assigned this role)
|
|
6
|
-
*/
|
|
7
|
-
const roleSchema = new Schema(
|
|
8
|
-
{
|
|
9
|
-
...createBaseSchema(),
|
|
10
|
-
name: { type: String, required: true, unique: true, trim: true },
|
|
11
|
-
description: { type: String, default: '' },
|
|
12
|
-
permissionIds: [{ type: String, ref: 'Permission' }]
|
|
13
|
-
},
|
|
14
|
-
baseSchemaOptions
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
roleSchema.index({ name: 1 });
|
|
18
|
-
|
|
19
|
-
const Role = model('Role', roleSchema);
|
|
20
|
-
|
|
21
|
-
module.exports = { Role };
|