@resolveio/server-lib 6.4.7-newrole → 6.4.7
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/collections/user.collection.js +32 -39
- package/collections/user.collection.js.map +1 -1
- package/methods/accounts.js.map +1 -1
- package/methods/cron-jobs.js.map +1 -1
- package/methods/report-builder.js +0 -3
- package/methods/report-builder.js.map +1 -1
- package/models/user.model.d.ts +14 -25
- package/models/user.model.js.map +1 -1
- package/package.json +1 -1
- package/publications/report-builder-libraries.js +3 -2
- package/publications/report-builder-libraries.js.map +1 -1
|
@@ -22,6 +22,13 @@ var schema = {
|
|
|
22
22
|
type: Date,
|
|
23
23
|
optional: true
|
|
24
24
|
},
|
|
25
|
+
readonly: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
optional: true
|
|
28
|
+
},
|
|
29
|
+
active: {
|
|
30
|
+
type: Boolean
|
|
31
|
+
},
|
|
25
32
|
attempts: {
|
|
26
33
|
type: Number,
|
|
27
34
|
optional: true
|
|
@@ -58,67 +65,53 @@ var schema = {
|
|
|
58
65
|
type: String
|
|
59
66
|
},
|
|
60
67
|
roles: {
|
|
61
|
-
type: Object
|
|
62
|
-
},
|
|
63
|
-
'roles.super_admin': {
|
|
64
|
-
type: Boolean
|
|
65
|
-
},
|
|
66
|
-
'roles.approvals': {
|
|
67
68
|
type: Array
|
|
68
69
|
},
|
|
69
|
-
'roles
|
|
70
|
-
type: Object
|
|
71
|
-
},
|
|
72
|
-
'roles.approvals.$.name': {
|
|
70
|
+
'roles.$': {
|
|
73
71
|
type: String
|
|
74
72
|
},
|
|
75
|
-
|
|
76
|
-
type: String
|
|
73
|
+
phonenumber: {
|
|
74
|
+
type: String,
|
|
75
|
+
optional: true
|
|
77
76
|
},
|
|
78
|
-
|
|
79
|
-
type:
|
|
77
|
+
other: {
|
|
78
|
+
type: Object,
|
|
79
|
+
blackbox: true,
|
|
80
|
+
optional: true
|
|
80
81
|
},
|
|
81
|
-
|
|
82
|
-
type: Array
|
|
82
|
+
assets: {
|
|
83
|
+
type: Array,
|
|
84
|
+
optional: true
|
|
83
85
|
},
|
|
84
|
-
'
|
|
86
|
+
'assets.$': {
|
|
85
87
|
type: Object
|
|
86
88
|
},
|
|
87
|
-
'
|
|
89
|
+
'assets.$.type': {
|
|
88
90
|
type: String
|
|
89
91
|
},
|
|
90
|
-
'
|
|
91
|
-
type: Array
|
|
92
|
-
},
|
|
93
|
-
'roles.groups.$.views.$': {
|
|
92
|
+
'assets.$.id_asset': {
|
|
94
93
|
type: String
|
|
95
94
|
},
|
|
96
|
-
'
|
|
97
|
-
type: String
|
|
98
|
-
optional: true
|
|
95
|
+
'assets.$.asset_number': {
|
|
96
|
+
type: String
|
|
99
97
|
},
|
|
100
|
-
'
|
|
101
|
-
type:
|
|
98
|
+
'assets.$.ownership': {
|
|
99
|
+
type: String
|
|
102
100
|
},
|
|
103
|
-
'
|
|
101
|
+
'assets.$.ownership_driver': {
|
|
104
102
|
type: String
|
|
105
103
|
},
|
|
106
|
-
'
|
|
107
|
-
type:
|
|
104
|
+
'assets.$.date_start': {
|
|
105
|
+
type: Date
|
|
108
106
|
},
|
|
109
|
-
'
|
|
110
|
-
type:
|
|
107
|
+
'assets.$.date_end': {
|
|
108
|
+
type: Date,
|
|
109
|
+
optional: true
|
|
111
110
|
},
|
|
112
|
-
|
|
113
|
-
phonenumber: {
|
|
111
|
+
id_function: {
|
|
114
112
|
type: String,
|
|
115
113
|
optional: true
|
|
116
114
|
},
|
|
117
|
-
other: {
|
|
118
|
-
type: Object,
|
|
119
|
-
optional: true,
|
|
120
|
-
blackbox: true
|
|
121
|
-
},
|
|
122
115
|
customers: {
|
|
123
116
|
type: Array,
|
|
124
117
|
optional: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/user.collection.ts"],"names":[],"mappings":";;AAAA,qCAAwG;AACxG,+DAAiE;AACjE,6CAAwC;AACxC,kCAA2C;AAG3C,uEAA8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C,IAAI,SAAS,GAAmB,EAAE,CAAC;AAEnC,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,sCAAc,CAAC,SAAS,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC;AACnF,aAAK,CAAC,UAAU,CAAC,GAAG,qCAAa,CAAC,QAAQ,CAAC,CAAC","file":"user.collection.js","sourcesContent":["import { Schema, Model, PassportLocalDocument, PassportLocalModel, PassportLocalSchema} from 'mongoose';\nimport * as passportLocalMongoose from 'passport-local-mongoose';\nimport SimpleSchema from 'simpl-schema';\nimport { ResolveIOServer } from '../index';\nimport { UserModel } from '../models/user.model';\nimport { LookupTables } from '../models/report-builder.model';\nimport { buildRbSchema, buildRbLookups } from '../util/schema-report-builder';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\treadonly: {\n\t\ttype: Boolean,\n\t\toptional: true\n\t},\n\tactive: {\n\t\ttype: Boolean\n\t},\n\tattempts: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tlast: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tservices: {\n\t\ttype: Object,\n\t\toptional: true\n\t},\n\t'services.enrollment': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.forgot_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.reset_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tusername: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\temail: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tfullname: {\n\t\ttype: String\n\t},\n\troles: {\n\t\ttype: Array\n\t},\n\t'roles.$': {\n\t\ttype: String\n\t},\n\tphonenumber: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tother: {\n\t\ttype: Object,\n\t\tblackbox: true,\n\t\toptional: true\n\t},\n\tassets: {\n\t\ttype: Array,\n\t\toptional: true\n\t},\n\t'assets.$': {\n\t\ttype: Object\n\t},\n\t'assets.$.type': {\n\t\ttype: String\n\t},\n\t'assets.$.id_asset': {\n\t\ttype: String\n\t},\n\t'assets.$.asset_number': {\n\t\ttype: String\n\t},\n\t'assets.$.ownership': {\n\t\ttype: String\n\t},\n\t'assets.$.ownership_driver': {\n\t\ttype: String\n\t},\n\t'assets.$.date_start': {\n\t\ttype: Date\n\t},\n\t'assets.$.date_end': {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tid_function: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomers: {\n\t\ttype: Array,\n\t\toptional: true,\n\t},\n\t'customers.$': {\n\t\ttype: Object\n\t},\n\t'customers.$.id_customer': {\n\t\ttype: String\n\t},\n\t'customers.$.customer': {\n\t\ttype: String\n\t},\n\tid_customer: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomer: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomer_type: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tdepartments: {\n\t\ttype: Array,\n\t\toptional: true\n\t},\n\t'departments.$': {\n\t\ttype: Object\n\t},\n\t'departments.$.id_department': {\n\t\ttype: String\n\t},\n\t'departments.$.department': {\n\t\ttype: String\n\t}\n};\n\nconst DefaultSchema = <PassportLocalSchema>new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\nDefaultSchema.plugin(passportLocalMongoose, {\n\tusernameUnique: true,\n\tlimitAttempts: true,\n\tmaxAttempts: 5,\n\tfindByUsername: (mongooseModel, queryParameters) => {\n\t\t// Add additional query parameter - AND condition - active: true\n\t\tqueryParameters.active = true;\n\t\treturn mongooseModel.findOne(queryParameters);\n\t}\n});\n\ninterface ResolveIOModel extends UserModel, PassportLocalDocument {}\nexport const Users: PassportLocalModel<ResolveIOModel> = (<any>ResolveIOServer.getMainDB()).model('users', DefaultSchema);\n\nexport let ClientUsers: PassportLocalModel<ResolveIOModel> = null;\n\nif (ResolveIOServer.getSupportDB()) {\n\tClientUsers = (<any>ResolveIOServer.getSupportDB()).model('client-users', DefaultSchema);\n}\n\nUsers['simplschema'] = new SimpleSchema(schema);\n\nschema._id = {\n\ttype: Schema.Types.Mixed\n};\n\nlet VersionSchema = new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\nVersionSchema.index({'_id.__v': 1, '_id._id': 1});\n\nUsers['versionCollection'] = 'users.versions';\n\nexport const UserVersions: Model<ResolveIOModel> = ResolveIOServer.getMainDB().model(Users['versionCollection'], VersionSchema);\n\n//------------- Report Builder Schema\nlet rbLookups: LookupTables[] = [];\n\nlet rbSchema = Object.assign(schema, buildRbLookups(rbLookups, DefaultSchema, []));\nUsers['rbSchema'] = buildRbSchema(rbSchema);"]}
|
package/methods/accounts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/methods/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwC;AACxC,qCAAiC;AACjC,kEAAuD;AACvD,uCAAyC;AACzC,kCAAoC;AACpC,wFAA0E;AAC1E,sFAA0E;AAE1E,kCAA2C;AAG3C,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACrB,eAAe,EAAE;YAChB,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,OAAO,EAAE,MAAM;aACf,CAAC;YACF,QAAQ,EAAE,UAAS,OAAO;gBACzB,OAAO,0CAAa,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,WAAW,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC,IAAI,EAAE,CAA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C,CAAC,CAAC,CAAC;iCACH;;;;qBACD,CAAC,CAAC;YACJ,CAAC;SACD;KACD,CAAC,CAAC;AACJ,CAAC;AAlMD,gDAkMC;AAED,SAAS,YAAY,CAAC,MAAM,EAAE,KAAK;IAClC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;KAAE;IAC/F,OAAO,MAAM,CAAC;AACf,CAAC","file":"accounts.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { Types } from 'mongoose';\nimport { Users } from '../collections/user.collection';\nimport * as handlebars from 'handlebars';\nimport * as jwt from 'jsonwebtoken';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { QueueResponses } from '../collections/queue-response.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../index';\nimport { UserModel } from '../models/user.model';\n\nexport function loadAccountMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tsetWSAppVersion: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tversion: Number\n\t\t\t}),\n\t\t\tfunction: function(version) {\n\t\t\t\treturn LoggedInUsers.updateOne({id_ws: this.id_ws}, {$set: {app_version: version}}).exec();\n\t\t\t}\n\t\t},\n\t\treloadWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'reloadWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'reloadWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t}).then(val => {\n\t\t\t\t\t\t// console.log(val);\n\t\t\t\t\t}, err => {\n\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\treconnectWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'reconnectWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'reconnectWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tdisconnectWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'disconnectWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'disconnectWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcreateUserAndEmailEnrollment: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tdata: {\n\t\t\t\t\ttype: Users['simplschema']\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(data) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet userId = Types.ObjectId().toHexString();\n\n\t\t\t\t\tlet newUser = {\n\t\t\t\t\t\t_id: userId,\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tusername: data.username, \n\t\t\t\t\t\temail: data.email,\n\t\t\t\t\t\tfullname: data.fullname,\n\t\t\t\t\t\troles: data.roles,\n\t\t\t\t\t\tactive: true,\n\t\t\t\t\t\treadonly: false,\n\t\t\t\t\t\tservices: {\n\t\t\t\t\t\t\tenrollment: jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\t\texpiresIn : 3 * 24 * 60 * 60 * 1000 // 3 days\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t},\n\t\t\t\t\t\tphonenumber: data.phonenumber,\n\t\t\t\t\t\tother: {}\n\t\t\t\t\t};\n\n\t\t\t\t\tif (data['departments']) {\n\t\t\t\t\t\tnewUser['departments'] = data['departments'];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (data['other']) {\n\t\t\t\t\t\tnewUser['other'] = data['other'];\n\t\t\t\t\t}\n\n\t\t\t\t\tlet user = await Users.create(newUser);\n\n\t\t\t\t\tuser.setPassword(randomString(20, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), ((err, res) => {\n\t\t\t\t\t\tuser.resetAttempts();\n\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tfullname: user.fullname,\n\t\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/enroll-account?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + user.services.enrollment\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.readFile('email-templates/enrollment.html').then(html => {\n\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\t\tthis.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Enrollment Email', '', template(emailData));\n\t\t\n\t\t\t\t\t\t\tresolve(user);\n\t\t\t\t\t\t}, errEmail => reject(errEmail));\n\t\t\t\t\t}));\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tresetUserPassword: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(userId: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\t\t\t\t\n\t\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\t\n\t\t\t\t\tif (user) {\n\n\t\t\t\t\t\tuser.services.forgot_password = jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET']);\n\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\t\tuserWhoResetPassword: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + user.services.forgot_password\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tUsers.updateOne({_id: user._id}, {$set: {services: user.services}}).exec((err, res) => {\n\t\t\t\t\t\t\tthis.readFile('email-templates/forgot-password.html').then(html => {\n\t\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\t\tthis.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData));\n\t\t\t\n\t\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t\t}, errEmail => reject(errEmail));\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n}\n\nfunction randomString(length, chars) {\n\tlet result = '';\n\tfor (let i = length; i > 0; --i) { result += chars[Math.floor(Math.random() * chars.length)]; }\n\treturn result;\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/methods/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwC;AACxC,qCAAiC;AACjC,kEAAuD;AACvD,uCAAyC;AACzC,kCAAoC;AACpC,wFAA0E;AAC1E,sFAA0E;AAE1E,kCAA2C;AAG3C,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACrB,eAAe,EAAE;YAChB,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,OAAO,EAAE,MAAM;aACf,CAAC;YACF,QAAQ,EAAE,UAAS,OAAO;gBACzB,OAAO,0CAAa,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAC,EAAE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UAAA,QAAQ,IAAI,OAAA,MAAM,CAAC,QAAQ,CAAC,EAAhB,CAAgB,CAAC,CAAC;oCAClC,CAAC,CAAC,CAAC;iCACH;;;;qBACD,CAAC,CAAC;YACJ,CAAC;SACD;KACD,CAAC,CAAC;AACJ,CAAC;AAlMD,gDAkMC;AAED,SAAS,YAAY,CAAC,MAAM,EAAE,KAAK;IAClC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;KAAE;IAC/F,OAAO,MAAM,CAAC;AACf,CAAC","file":"accounts.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { Types } from 'mongoose';\nimport { Users } from '../collections/user.collection';\nimport * as handlebars from 'handlebars';\nimport * as jwt from 'jsonwebtoken';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { QueueResponses } from '../collections/queue-response.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../index';\nimport { UserModel } from '../models/user.model';\n\nexport function loadAccountMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tsetWSAppVersion: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tversion: Number\n\t\t\t}),\n\t\t\tfunction: function(version) {\n\t\t\t\treturn LoggedInUsers.updateOne({id_ws: this.id_ws}, {$set: {app_version: version}}).exec();\n\t\t\t}\n\t\t},\n\t\treloadWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'reloadWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'reloadWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t}).then(val => {\n\t\t\t\t\t\t// console.log(val);\n\t\t\t\t\t}, err => {\n\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\treconnectWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'reconnectWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'reconnectWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tdisconnectWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'disconnectWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'disconnectWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcreateUserAndEmailEnrollment: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tdata: {\n\t\t\t\t\ttype: Users['simplschema']\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(data) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet userId = Types.ObjectId().toHexString();\n\n\t\t\t\t\tlet newUser = {\n\t\t\t\t\t\t_id: userId,\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tusername: data.username, \n\t\t\t\t\t\temail: data.email,\n\t\t\t\t\t\tfullname: data.fullname,\n\t\t\t\t\t\troles: data.roles,\n\t\t\t\t\t\tactive: true,\n\t\t\t\t\t\treadonly: false,\n\t\t\t\t\t\tservices: {\n\t\t\t\t\t\t\tenrollment: jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\t\texpiresIn : 3 * 24 * 60 * 60 * 1000 // 3 days\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t},\n\t\t\t\t\t\tphonenumber: data.phonenumber,\n\t\t\t\t\t\tother: {}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (data['departments']) {\n\t\t\t\t\t\tnewUser['departments'] = data['departments'];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (data['other']) {\n\t\t\t\t\t\tnewUser['other'] = data['other'];\n\t\t\t\t\t}\n\n\t\t\t\t\tlet user = await Users.create(newUser);\n\n\t\t\t\t\tuser.setPassword(randomString(20, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), ((err, res) => {\n\t\t\t\t\t\tuser.resetAttempts();\n\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tfullname: user.fullname,\n\t\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/enroll-account?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + user.services.enrollment\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.readFile('email-templates/enrollment.html').then(html => {\n\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\t\tthis.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Enrollment Email', '', template(emailData));\n\t\t\n\t\t\t\t\t\t\tresolve(user);\n\t\t\t\t\t\t}, errEmail => reject(errEmail));\n\t\t\t\t\t}));\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tresetUserPassword: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(userId: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\t\t\t\t\n\t\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\t\n\t\t\t\t\tif (user) {\n\n\t\t\t\t\t\tuser.services.forgot_password = jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET']);\n\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\t\tuserWhoResetPassword: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + user.services.forgot_password\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tUsers.updateOne({_id: user._id}, {$set: {services: user.services}}).exec((err, res) => {\n\t\t\t\t\t\t\tthis.readFile('email-templates/forgot-password.html').then(html => {\n\t\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\t\tthis.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData));\n\t\t\t\n\t\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t\t}, errEmail => reject(errEmail));\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n}\n\nfunction randomString(length, chars) {\n\tlet result = '';\n\tfor (let i = length; i > 0; --i) { result += chars[Math.floor(Math.random() * chars.length)]; }\n\treturn result;\n}"]}
|