@resolveio/server-lib 20.10.7 → 20.11.0

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyC;AACzC,kCAAoC;AACpC,6CAAwC;AACxC,kEAAuD;AAGvD,gEAA0D;AAC1D,yCAAmD;AAEnD,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACrB,aAAa,EAAE;YACd,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,QAAQ,EAAE;oBACT,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,QAAQ,EAAE;oBACT,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,WAAW,EAAE;oBACZ,IAAI,EAAE,KAAK;iBACX;gBACD,eAAe,EAAE;oBAChB,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,IAAI;iBACd;aACD,CAAC;YACF,QAAQ,EAAE,UAAe,QAAQ,EAAE,QAAQ,EAAE,WAAW;;;;;;qCACnD,sCAAe,CAAC,aAAa,EAAE,EAA/B,wBAA+B;gCAC9B,EAAE,GAAG,sCAAe,CAAC,aAAa,EAAE,CAAC,mBAAmB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gCACxF,qBAAM,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,iCAAiC,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,gBAAgB,GAAG,IAAI,CAAC,IAAI,GAAG,kBAAkB,GAAG,IAAI,CAAC,OAAO,GAAG,0BAA0B,GAAG,IAAI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AAA,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAA,EAA/B,wBAA+B;gCAClC,qBAAM,uBAAK,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAA;;gCAAvC,SAAuC,CAAC;gCAExC,sBAAO,IAAI,EAAC;oCAGZ,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;;;;aAE7D;SACD;KACD,CAAC,CAAC;AACJ,CAAC;AAjND,gDAiNC","file":"accounts.js","sourcesContent":["import * as handlebars from 'handlebars';\nimport * as jwt from 'jsonwebtoken';\nimport SimpleSchema from 'simpl-schema';\nimport { Users } from '../collections/user.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { UserModel } from '../models/user.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\n\nexport function loadAccountMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tincorrectUser: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\told_user: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tnew_user: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tclient_subs: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'client_subs.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(old_user, new_user, client_subs) {\n\t\t\t\tif (ResolveIOServer.getMainServer()) {\n\t\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWebSocketManager().getWebSocket(this.id_ws);\n\t\t\t\t\tawait this.sendEmail('dev@resolveio.com', 'SERVER - WRONG USER Detected - ' + this.serverConfig['CLIENT_NAME'], 'Wrong User Sent!\\nWS: ' + JSON.stringify(ws, null, 2) + '\\nUserMethod: ' + this.user + '\\nIdUserMethod: ' + this.id_user + '\\nSubManagerActiveSubs: ' + JSON.stringify(ResolveIOServer.getMainServer().getSubscriptionManager().getActiveSubscriptions(), null, 2) + '\\nOldUser: ' + JSON.stringify(old_user, null, 2) + '\\nNewUser: ' + JSON.stringify(new_user, null, 2) + '\\nClientSubs: ' + JSON.stringify(client_subs, null, 2));\n\t\t\t\t}\n\n\t\t\t\treturn Promise.resolve(null);\n\t\t\t}\n\t\t},\n\t\treloadWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: async function(id_ws) {\n\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWebSocketManager().getWebSocket(id_ws);\n\n\t\t\t\tif (ws) {\n\t\t\t\t\tawait ResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new Error('Error in Reload WS: No WS');\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\treconnectWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: async function(id_ws) {\n\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWebSocketManager().getWebSocket(id_ws);\n\n\t\t\t\tif (ws) {\n\t\t\t\t\tawait ResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new Error('Error in Reconnect WS: No WS');\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tdisconnectWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: async function(id_ws) {\n\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWebSocketManager().getWebSocket(id_ws);\n\n\t\t\t\tif (ws) {\n\t\t\t\t\tawait ResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new Error('Error in Disconnect WS: No WS');\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\tnewUser: {\n\t\t\t\t\ttype: Users['simplschema']\n\t\t\t\t},\n\t\t\t\tsendEnrollmentEmail: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(newUser: UserModel, sendEnrollmentEmail = true) {\n\t\t\t\tif (newUser.username.toLocaleLowerCase() === 'admin') {\n\t\t\t\t\tthrow new Error('Error in Create User And Email Enrollment: Username can not be admin');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet otherUser = await Users.findOne({\n\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t{username: newUser.username.toLocaleLowerCase()},\n\t\t\t\t\t\t\t{email: newUser.email.toLocaleLowerCase()}\n\t\t\t\t\t\t]\n\t\t\t\t\t});\n\n\t\t\t\t\tif (otherUser) {\n\t\t\t\t\t\tthrow new Error('Error in Create User And Email Enrollment: Username/Email is already used');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tnewUser._id = objectIdHexString();\n\n\t\t\t\tnewUser.services = {\n\t\t\t\t\tenrollment: jwt.sign({id_user: newUser._id}, this.serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\texpiresIn : 3 * 24 * 60 * 60 * 1000 // 3 days\n\t\t\t\t\t})\n\t\t\t\t};\n\n\t\t\t\tnewUser.is_customer = false;\n\t\t\t\tawait Users.insertOne(newUser);\n\n\t\t\t\tif (sendEnrollmentEmail) {\n\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\tfullname: newUser.fullname,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\turl: (this.serverConfig['ROOT_URL'] + '/enroll-account?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + newUser.services['enrollment'])\n\t\t\t\t\t};\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet html = this.readFile('email-templates/enrollment.html');\n\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tawait this.sendEmail(newUser.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Enrollment Email', '', template(emailData), null, null, '');\n\n\t\t\t\t\t\treturn newUser;\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\terr.message = `Error in Create User And Email Enrollment: email-templates/enrollment.html - ${err.message}`;\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treturn newUser;\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: async function(userId: string) {\n\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\n\t\t\t\tif (user) {\n\t\t\t\t\tif (!user.services) {\n\t\t\t\t\t\tuser.services = {};\n\t\t\t\t\t}\n\n\t\t\t\t\tuser.services['forgot_password'] = jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET']);\n\n\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\tuserWhoResetPassword: this.user,\n\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};\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait Users.updateOne({_id: user._id}, {$set: {services: user.services, attempts: 0}});\n\t\t\t\t\t\tlet html = this.readFile('email-templates/forgot-password.html');\n\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\tawait this.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData), null, null, '');\n\t\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\terr.message = `Error in Reset User Password: email-templates/forgot-password.html - ${err.message}`;\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthrow new Error('Error in Reset User Password: Invalid User');\n\t\t\t}\n\t\t},\n\t\tsetUserPassword: {\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\tpassword: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(userId: string, password: string) {\n\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\n\t\t\t\tif (user && !user.roles.super_admin) {\n\t\t\t\t\tawait Users.setPassword(user, password);\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new Error('Error in Set User Password: Invalid User');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n}"]}
1
+ {"version":3,"sources":["../../src/methods/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyC;AACzC,kCAAoC;AACpC,6CAAwC;AACxC,kEAAuD;AAGvD,gEAA0D;AAC1D,yCAAmD;AACnD,yDAAuD;AAEvD,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACrB,aAAa,EAAE;YACd,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,QAAQ,EAAE;oBACT,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE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,CAAC;gCAChB,CAAC,CAAC,CAAC;gCAEH,qBAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,sCAAe,CAAC,aAAa,EAAE,GAAG,qBAAqB,EAAE,EAAE,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,EAAA;;gCAAlJ,SAAkJ,CAAC;gCAEnJ,sBAAO,IAAI,EAAC;;;gCAGZ,KAAG,CAAC,OAAO,GAAG,+EAAwE,KAAG,CAAC,OAAO,CAAE,CAAC;gCACpG,MAAM,KAAG,CAAC;oCAIZ,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;;;;aAC9D;SACD;QACD,eAAe,EAAE;YAChB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,MAAM,EAAE;oBACP,IAAI,EAAE,MAAM;iBACZ;gBACD,QAAQ,EAAE;oBACT,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAe,MAAc,EAAE,QAAgB;;;;;oCAC7C,qBAAM,uBAAK,CAAC,OAAO,CAAC,EAAC,GAAG,EAAE,MAAM,EAAC,CAAC,EAAA;;gCAAzC,IAAI,GAAG,SAAkC;qCAEzC,CAAA,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAA,EAA/B,wBAA+B;gCAClC,qBAAM,uBAAK,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAA;;gCAAvC,SAAuC,CAAC;gCAExC,sBAAO,IAAI,EAAC;oCAGZ,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;;;;aAE7D;SACD;KACD,CAAC,CAAC;AACJ,CAAC;AAtOD,gDAsOC","file":"accounts.js","sourcesContent":["import * as handlebars from 'handlebars';\nimport * as jwt from 'jsonwebtoken';\nimport SimpleSchema from 'simpl-schema';\nimport { Users } from '../collections/user.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { UserModel } from '../models/user.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\nimport { ErrorReporter } from '../util/error-reporter';\n\nexport function loadAccountMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tincorrectUser: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\told_user: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tnew_user: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tclient_subs: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'client_subs.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(old_user, new_user, client_subs) {\n\t\t\t\tif (ResolveIOServer.getMainServer()) {\n\t\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWebSocketManager().getWebSocket(this.id_ws);\n\t\t\t\t\tconst correlationId = objectIdHexString();\n\t\t\t\t\tawait ErrorReporter.report({\n\t\t\t\t\t\tsourceApp: 'method-accounts',\n\t\t\t\t\t\tmessage: 'SERVER - WRONG USER Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tenvironment: this.serverConfig?.ROOT_URL,\n\t\t\t\t\t\tclientSlug: ResolveIOServer.getClientName(),\n\t\t\t\t\t\tclientName: this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\tws,\n\t\t\t\t\t\t\tuserMethod: this.user,\n\t\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\t\tactiveSubs: ResolveIOServer.getMainServer().getSubscriptionManager().getActiveSubscriptions(),\n\t\t\t\t\t\t\told_user,\n\t\t\t\t\t\t\tnew_user,\n\t\t\t\t\t\t\tclient_subs\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tcontext: 'incorrectUser',\n\t\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn Promise.resolve(null);\n\t\t\t}\n\t\t},\n\t\treloadWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: async function(id_ws) {\n\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWebSocketManager().getWebSocket(id_ws);\n\n\t\t\t\tif (ws) {\n\t\t\t\t\tawait ResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new Error('Error in Reload WS: No WS');\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\treconnectWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: async function(id_ws) {\n\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWebSocketManager().getWebSocket(id_ws);\n\n\t\t\t\tif (ws) {\n\t\t\t\t\tawait ResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new Error('Error in Reconnect WS: No WS');\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tdisconnectWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: async function(id_ws) {\n\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWebSocketManager().getWebSocket(id_ws);\n\n\t\t\t\tif (ws) {\n\t\t\t\t\tawait ResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new Error('Error in Disconnect WS: No WS');\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\tnewUser: {\n\t\t\t\t\ttype: Users['simplschema']\n\t\t\t\t},\n\t\t\t\tsendEnrollmentEmail: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(newUser: UserModel, sendEnrollmentEmail = true) {\n\t\t\t\tif (newUser.username.toLocaleLowerCase() === 'admin') {\n\t\t\t\t\tthrow new Error('Error in Create User And Email Enrollment: Username can not be admin');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet otherUser = await Users.findOne({\n\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t{username: newUser.username.toLocaleLowerCase()},\n\t\t\t\t\t\t\t{email: newUser.email.toLocaleLowerCase()}\n\t\t\t\t\t\t]\n\t\t\t\t\t});\n\n\t\t\t\t\tif (otherUser) {\n\t\t\t\t\t\tthrow new Error('Error in Create User And Email Enrollment: Username/Email is already used');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tnewUser._id = objectIdHexString();\n\n\t\t\t\tnewUser.services = {\n\t\t\t\t\tenrollment: jwt.sign({id_user: newUser._id}, this.serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\texpiresIn : 3 * 24 * 60 * 60 * 1000 // 3 days\n\t\t\t\t\t})\n\t\t\t\t};\n\n\t\t\t\tnewUser.is_customer = false;\n\t\t\t\tawait Users.insertOne(newUser);\n\n\t\t\t\tif (sendEnrollmentEmail) {\n\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\tfullname: newUser.fullname,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\turl: (this.serverConfig['ROOT_URL'] + '/enroll-account?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + newUser.services['enrollment'])\n\t\t\t\t\t};\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet html = this.readFile('email-templates/enrollment.html');\n\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tawait this.sendEmail(newUser.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Enrollment Email', '', template(emailData), null, null, '');\n\n\t\t\t\t\t\treturn newUser;\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\terr.message = `Error in Create User And Email Enrollment: email-templates/enrollment.html - ${err.message}`;\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treturn newUser;\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: async function(userId: string) {\n\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\n\t\t\t\tif (user) {\n\t\t\t\t\tif (!user.services) {\n\t\t\t\t\t\tuser.services = {};\n\t\t\t\t\t}\n\n\t\t\t\t\tuser.services['forgot_password'] = jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET']);\n\n\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\tuserWhoResetPassword: this.user,\n\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};\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait Users.updateOne({_id: user._id}, {$set: {services: user.services, attempts: 0}});\n\t\t\t\t\t\tlet html = this.readFile('email-templates/forgot-password.html');\n\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\tawait this.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData), null, null, '');\n\t\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\terr.message = `Error in Reset User Password: email-templates/forgot-password.html - ${err.message}`;\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthrow new Error('Error in Reset User Password: Invalid User');\n\t\t\t}\n\t\t},\n\t\tsetUserPassword: {\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\tpassword: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(userId: string, password: string) {\n\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\n\t\t\t\tif (user && !user.roles.super_admin) {\n\t\t\t\t\tawait Users.setPassword(user, password);\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new Error('Error in Set User Password: Invalid User');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n}\n"]}
@@ -457,7 +457,7 @@ function loadCronJobMethods(methodManager) {
457
457
  _k.label = 4;
458
458
  case 4:
459
459
  _k.trys.push([4, 41, , 42]);
460
- return [4 /*yield*/, this.callMethod('reportBuilderGetResults', report.type, report.collection_root, rootOptions, filters_1, filterArrays_1, filterArrayFields_1, report.fields_selected, report.fields_custom, report.groups_row, report.fields_total, report.fields_link, report.id_date_field || null, report.date_interval || null, report.group_type, report.collection_joins || [])];
460
+ return [4 /*yield*/, this.callMethod('reportBuilderGetResults', report.type, report.collection_root, rootOptions, filters_1, filterArrays_1, filterArrayFields_1, report.fields_selected, report.fields_custom, report.groups_row, report.fields_total, report.fields_link, report.id_date_field || null, report.date_interval || null, report.group_type)];
461
461
  case 5:
462
462
  res = _k.sent();
463
463
  if (!(res && res[0])) return [3 /*break*/, 40];