Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / userProfile / userProfile.controller.js
index 54d6460..3fa5fc1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe1d7=['undefined','limit','count','Content-Range','apply','reject','save','update','destroy','then','end','error','stack','name','send','index','map','UserProfile','rawAttributes','fieldName','type','key','query','keys','intersection','model','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','include','findAll','catch','show','params','find','body','clone','get','createdAt','updatedAt','crudPermissions','omit','sequelize','transaction','create','UserProfileSection','each','autoAssociation','UserProfileResource','sectionId','Resources','describe','addSections','userProfileId','removeSections','getSections','enabled','includes','isEmpty','subsections','findOne','Dashboard','forEach','push','resourceId','Plugin','bulkCreate','removeResources','ids','getResources','section','Missing\x20section\x20parameter','No\x20User\x20Profile\x20found\x20for\x20id\x20','rimraf','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./userProfile.socket','register','sendStatus','status','json','offset'];(function(_0x4e9e00,_0x157820){var _0x201de0=function(_0x3217d5){while(--_0x3217d5){_0x4e9e00['push'](_0x4e9e00['shift']());}};_0x201de0(++_0x157820);}(_0xe1d7,0x1a9));var _0x7e1d=function(_0x596f3f,_0x53c5bf){_0x596f3f=_0x596f3f-0x0;var _0x2c1225=_0xe1d7[_0x596f3f];return _0x2c1225;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x7e1d('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x7e1d('0x1'));var BPromise=require(_0x7e1d('0x2'));var Mustache=require(_0x7e1d('0x3'));var util=require('util');var path=require(_0x7e1d('0x4'));var sox=require(_0x7e1d('0x5'));var csv=require(_0x7e1d('0x6'));var ejs=require(_0x7e1d('0x7'));var fs=require('fs');var fs_extra=require(_0x7e1d('0x8'));var _=require('lodash');var squel=require(_0x7e1d('0x9'));var crypto=require(_0x7e1d('0xa'));var jsforce=require('jsforce');var deskjs=require(_0x7e1d('0xb'));var toCsv=require(_0x7e1d('0x6'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x7e1d('0xc'));var authService=require(_0x7e1d('0xd'));var qs=require(_0x7e1d('0xe'));var as=require(_0x7e1d('0xf'));var hardwareService=require(_0x7e1d('0x10'));var logger=require(_0x7e1d('0x11'))(_0x7e1d('0x12'));var utils=require('../../config/utils');var config=require(_0x7e1d('0x13'));var licenseUtil=require(_0x7e1d('0x14'));var db=require(_0x7e1d('0x15'))['db'];config[_0x7e1d('0x16')]=_['defaults'](config[_0x7e1d('0x16')],{'host':_0x7e1d('0x17'),'port':0x18eb});var socket=require(_0x7e1d('0x18'))(new Redis(config['redis']));require(_0x7e1d('0x19'))[_0x7e1d('0x1a')](socket);function respondWithStatusCode(_0x5cafde,_0x514641){_0x514641=_0x514641||0xcc;return function(_0x401fe1){if(_0x401fe1){return _0x5cafde[_0x7e1d('0x1b')](_0x514641);}return _0x5cafde[_0x7e1d('0x1c')](_0x514641)['end']();};}function respondWithResult(_0x25f214,_0x2420e8){_0x2420e8=_0x2420e8||0xc8;return function(_0x528fd0){if(_0x528fd0){return _0x25f214[_0x7e1d('0x1c')](_0x2420e8)[_0x7e1d('0x1d')](_0x528fd0);}};}function respondWithFilteredResult(_0x3eb945,_0x2e6067){return function(_0x5a9abe){if(_0x5a9abe){var _0x15dcbe=typeof _0x2e6067[_0x7e1d('0x1e')]===_0x7e1d('0x1f')&&typeof _0x2e6067[_0x7e1d('0x20')]===_0x7e1d('0x1f');var _0x3671d3=_0x5a9abe[_0x7e1d('0x21')];var _0x52cd38=_0x15dcbe?0x0:_0x2e6067[_0x7e1d('0x1e')];var _0x32cecb=_0x15dcbe?_0x5a9abe[_0x7e1d('0x21')]:_0x2e6067[_0x7e1d('0x1e')]+_0x2e6067[_0x7e1d('0x20')];var _0x5480fe;if(_0x32cecb>=_0x3671d3){_0x32cecb=_0x3671d3;_0x5480fe=0xc8;}else{_0x5480fe=0xce;}_0x3eb945['status'](_0x5480fe);return _0x3eb945['set'](_0x7e1d('0x22'),_0x52cd38+'-'+_0x32cecb+'/'+_0x3671d3)[_0x7e1d('0x1d')](_0x5a9abe);}return null;};}function patchUpdates(_0x30229f){return function(_0x49ea3a){try{jsonpatch[_0x7e1d('0x23')](_0x49ea3a,_0x30229f,!![]);}catch(_0x56653f){return BPromise[_0x7e1d('0x24')](_0x56653f);}return _0x49ea3a[_0x7e1d('0x25')]();};}function saveUpdates(_0xcc5980,_0x221ed5){return function(_0x16e753){if(_0x16e753){return _0x16e753[_0x7e1d('0x26')](_0xcc5980)['then'](function(_0x1fd926){return _0x1fd926;});}return null;};}function removeEntity(_0x45473a,_0x12ba7f){return function(_0x194765){if(_0x194765){return _0x194765[_0x7e1d('0x27')]()[_0x7e1d('0x28')](function(){_0x45473a[_0x7e1d('0x1c')](0xcc)[_0x7e1d('0x29')]();});}};}function handleEntityNotFound(_0x50c8fd,_0x38bb7d){return function(_0x248b1a){if(!_0x248b1a){_0x50c8fd['sendStatus'](0x194);}return _0x248b1a;};}function handleError(_0x23adc5,_0x20fe65){_0x20fe65=_0x20fe65||0x1f4;return function(_0x4ebce1){logger[_0x7e1d('0x2a')](_0x4ebce1[_0x7e1d('0x2b')]);if(_0x4ebce1[_0x7e1d('0x2c')]){delete _0x4ebce1[_0x7e1d('0x2c')];}_0x23adc5[_0x7e1d('0x1c')](_0x20fe65)[_0x7e1d('0x2d')](_0x4ebce1);};}exports[_0x7e1d('0x2e')]=function(_0x7b6836,_0x12ad82){var _0x19f6ae={},_0x568746={},_0xfaefdb={'count':0x0,'rows':[]};var _0x3293bf=_[_0x7e1d('0x2f')](db[_0x7e1d('0x30')][_0x7e1d('0x31')],function(_0x416bf3){return{'name':_0x416bf3[_0x7e1d('0x32')],'type':_0x416bf3[_0x7e1d('0x33')][_0x7e1d('0x34')]};});_0x568746['model']=_['map'](_0x3293bf,_0x7e1d('0x2c'));_0x568746[_0x7e1d('0x35')]=_[_0x7e1d('0x36')](_0x7b6836[_0x7e1d('0x35')]);_0x568746['filters']=_[_0x7e1d('0x37')](_0x568746['model'],_0x568746[_0x7e1d('0x35')]);_0x19f6ae['attributes']=_[_0x7e1d('0x37')](_0x568746[_0x7e1d('0x38')],qs[_0x7e1d('0x39')](_0x7b6836['query'][_0x7e1d('0x39')]));_0x19f6ae[_0x7e1d('0x3a')]=_0x19f6ae['attributes']['length']?_0x19f6ae['attributes']:_0x568746[_0x7e1d('0x38')];if(!_0x7b6836[_0x7e1d('0x35')][_0x7e1d('0x3b')](_0x7e1d('0x3c'))){_0x19f6ae[_0x7e1d('0x20')]=qs['limit'](_0x7b6836['query'][_0x7e1d('0x20')]);_0x19f6ae[_0x7e1d('0x1e')]=qs['offset'](_0x7b6836[_0x7e1d('0x35')][_0x7e1d('0x1e')]);}_0x19f6ae[_0x7e1d('0x3d')]=qs[_0x7e1d('0x3e')](_0x7b6836[_0x7e1d('0x35')]['sort']);_0x19f6ae[_0x7e1d('0x3f')]=qs['filters'](_[_0x7e1d('0x40')](_0x7b6836[_0x7e1d('0x35')],_0x568746['filters']),_0x3293bf);if(_0x7b6836[_0x7e1d('0x35')]['filter']){_0x19f6ae[_0x7e1d('0x3f')]=_[_0x7e1d('0x41')](_0x19f6ae[_0x7e1d('0x3f')],{'$or':_[_0x7e1d('0x2f')](_0x3293bf,function(_0x30c8e9){if(_0x30c8e9[_0x7e1d('0x33')]!==_0x7e1d('0x42')){var _0x507b95={};_0x507b95[_0x30c8e9[_0x7e1d('0x2c')]]={'$like':'%'+_0x7b6836[_0x7e1d('0x35')][_0x7e1d('0x43')]+'%'};return _0x507b95;}})});}_0x19f6ae=_[_0x7e1d('0x41')]({},_0x19f6ae,_0x7b6836[_0x7e1d('0x44')]);var _0x2f939e={'where':_0x19f6ae[_0x7e1d('0x3f')]};return db[_0x7e1d('0x30')][_0x7e1d('0x21')](_0x2f939e)[_0x7e1d('0x28')](function(_0x5dd3f6){_0xfaefdb[_0x7e1d('0x21')]=_0x5dd3f6;if(_0x7b6836[_0x7e1d('0x35')][_0x7e1d('0x45')]){_0x19f6ae[_0x7e1d('0x46')]=[{'all':!![]}];}return db[_0x7e1d('0x30')][_0x7e1d('0x47')](_0x19f6ae);})[_0x7e1d('0x28')](function(_0x5959){_0xfaefdb['rows']=_0x5959;return _0xfaefdb;})[_0x7e1d('0x28')](respondWithFilteredResult(_0x12ad82,_0x19f6ae))[_0x7e1d('0x48')](handleError(_0x12ad82,null));};exports[_0x7e1d('0x49')]=function(_0x149fa6,_0xf8e424){var _0x485f34={'raw':![],'where':{'id':_0x149fa6[_0x7e1d('0x4a')]['id']}},_0x448a6b={};_0x448a6b[_0x7e1d('0x38')]=_['keys'](db['UserProfile'][_0x7e1d('0x31')]);_0x448a6b['query']=_[_0x7e1d('0x36')](_0x149fa6[_0x7e1d('0x35')]);_0x448a6b['filters']=_[_0x7e1d('0x37')](_0x448a6b[_0x7e1d('0x38')],_0x448a6b[_0x7e1d('0x35')]);_0x485f34['attributes']=_[_0x7e1d('0x37')](_0x448a6b['model'],qs[_0x7e1d('0x39')](_0x149fa6[_0x7e1d('0x35')][_0x7e1d('0x39')]));_0x485f34[_0x7e1d('0x3a')]=_0x485f34[_0x7e1d('0x3a')]['length']?_0x485f34[_0x7e1d('0x3a')]:_0x448a6b[_0x7e1d('0x38')];if(_0x149fa6['query'][_0x7e1d('0x45')]){_0x485f34[_0x7e1d('0x46')]=[{'all':!![]}];}_0x485f34=_[_0x7e1d('0x41')]({},_0x485f34,_0x149fa6['options']);return db['UserProfile'][_0x7e1d('0x4b')](_0x485f34)[_0x7e1d('0x28')](handleEntityNotFound(_0xf8e424,null))[_0x7e1d('0x28')](respondWithResult(_0xf8e424,null))[_0x7e1d('0x48')](handleError(_0xf8e424,null));};exports['create']=function(_0x395b11,_0x2a107a){return db[_0x7e1d('0x30')]['create'](_0x395b11[_0x7e1d('0x4c')],{})[_0x7e1d('0x28')](respondWithResult(_0x2a107a,0xc9))['catch'](handleError(_0x2a107a,null));};exports[_0x7e1d('0x4d')]=function(_0x443294,_0x23ebdf){var _0x46f6e8={'where':{'id':_0x443294['params']['id']}},_0x552900={};_0x552900[_0x7e1d('0x38')]=_[_0x7e1d('0x36')](db[_0x7e1d('0x30')]['rawAttributes']);_0x46f6e8[_0x7e1d('0x3a')]=_['intersection'](_0x552900['model'],qs[_0x7e1d('0x39')](_0x443294[_0x7e1d('0x35')][_0x7e1d('0x39')]));_0x46f6e8[_0x7e1d('0x3a')]=_0x46f6e8[_0x7e1d('0x3a')]['length']?_0x46f6e8['attributes']:_0x552900[_0x7e1d('0x38')];if(_0x443294['query']['includeAll']){_0x46f6e8['include']=[{'all':!![]}];}_0x46f6e8=_['merge']({},_0x46f6e8,_0x443294[_0x7e1d('0x44')]);return db[_0x7e1d('0x30')][_0x7e1d('0x4b')](_0x46f6e8)[_0x7e1d('0x28')](handleEntityNotFound(_0x23ebdf,null))['then'](function(_0x9a35cf){if(_0x9a35cf){var _0xa24982=_0x9a35cf[_0x7e1d('0x4e')]({'plain':!![]});_0xa24982=qs['omit'](_0xa24982,['id',_0x7e1d('0x4f'),_0x7e1d('0x50'),_0x7e1d('0x51')]);_0x443294[_0x7e1d('0x4c')]=_[_0x7e1d('0x52')](_0x443294[_0x7e1d('0x4c')],['id',_0x7e1d('0x4f'),'updatedAt']);return db[_0x7e1d('0x53')][_0x7e1d('0x54')](function(_0x5d5c0a){return db[_0x7e1d('0x30')][_0x7e1d('0x55')](_[_0x7e1d('0x41')](_0xa24982,_0x443294[_0x7e1d('0x4c')]),{'include':_0x443294[_0x7e1d('0x35')][_0x7e1d('0x45')]?[{'all':!![]}]:undefined,'transaction':_0x5d5c0a})[_0x7e1d('0x28')](function(_0x5c80ad){var _0x173511=_0x5c80ad[_0x7e1d('0x4e')]({'plain':!![]});return db[_0x7e1d('0x56')][_0x7e1d('0x47')]({'where':{'userProfileId':_0x443294[_0x7e1d('0x4a')]['id']},'raw':!![]})[_0x7e1d('0x28')](function(_0xf10186){if(_0xf10186){return BPromise[_0x7e1d('0x57')](_0xf10186,function(_0xfc1e37){return new BPromise(function(_0x6f25fc,_0x378aba){if(_0xfc1e37['autoAssociation']===null||_0xfc1e37[_0x7e1d('0x58')]===0x1)_0x6f25fc(null);return db[_0x7e1d('0x59')][_0x7e1d('0x47')]({'where':{'sectionId':_0xfc1e37['id']},'raw':!![]})['then'](function(_0x5c1b97){var _0x56dc54=_[_0x7e1d('0x2f')](_0x5c1b97,function(_0x12a1c7){return qs[_0x7e1d('0x52')](_0x12a1c7,['id',_0x7e1d('0x4f'),_0x7e1d('0x50'),_0x7e1d('0x5a')]);});_0x6f25fc(_0x56dc54);})[_0x7e1d('0x48')](function(_0x22eb12){_0x378aba(_0x22eb12);});})['then'](function(_0x2c6a5c){var _0x5d3551=qs[_0x7e1d('0x52')](_0xfc1e37,['id',_0x7e1d('0x4f'),_0x7e1d('0x50')]);_0x5d3551['userProfileId']=_0x173511['id'];if(_0x2c6a5c)_0x5d3551['Resources']=_0x2c6a5c;return _0x5d3551;})['then'](function(_0x639b25){return db[_0x7e1d('0x56')][_0x7e1d('0x55')](_0x639b25,{'include':[{'model':db[_0x7e1d('0x59')],'as':_0x7e1d('0x5b')}],'raw':!![],'transaction':_0x5d5c0a});});})[_0x7e1d('0x28')](function(){return _0x173511;});}});});});}})[_0x7e1d('0x28')](respondWithResult(_0x23ebdf,0xc9))[_0x7e1d('0x48')](handleError(_0x23ebdf,null));};exports[_0x7e1d('0x26')]=function(_0x13a222,_0x134a02){if(_0x13a222['body']['id']){delete _0x13a222[_0x7e1d('0x4c')]['id'];}return db[_0x7e1d('0x30')][_0x7e1d('0x4b')]({'where':{'id':_0x13a222[_0x7e1d('0x4a')]['id']}})[_0x7e1d('0x28')](handleEntityNotFound(_0x134a02,null))[_0x7e1d('0x28')](saveUpdates(_0x13a222[_0x7e1d('0x4c')],null))[_0x7e1d('0x28')](respondWithResult(_0x134a02,null))[_0x7e1d('0x48')](handleError(_0x134a02,null));};exports['destroy']=function(_0x2f24ac,_0x21284b){return db[_0x7e1d('0x30')]['find']({'where':{'id':_0x2f24ac[_0x7e1d('0x4a')]['id']}})[_0x7e1d('0x28')](handleEntityNotFound(_0x21284b,null))[_0x7e1d('0x28')](removeEntity(_0x21284b,null))[_0x7e1d('0x48')](handleError(_0x21284b,null));};exports[_0x7e1d('0x5c')]=function(_0x344571,_0x2ef4bb){return db['UserProfile'][_0x7e1d('0x5c')]()[_0x7e1d('0x28')](respondWithResult(_0x2ef4bb,null))[_0x7e1d('0x48')](handleError(_0x2ef4bb,null));};exports[_0x7e1d('0x5d')]=function(_0x42bed9,_0x2ac2e1){var _0x248fae=_0x42bed9['body'];return db[_0x7e1d('0x30')][_0x7e1d('0x4b')]({'where':{'id':_0x42bed9[_0x7e1d('0x4a')]['id']}})[_0x7e1d('0x28')](handleEntityNotFound(_0x2ac2e1,null))[_0x7e1d('0x28')](function(_0x1960f1){if(_0x1960f1){return db['sequelize'][_0x7e1d('0x54')](function(_0x538596){return db[_0x7e1d('0x56')][_0x7e1d('0x27')]({'where':{'userProfileId':_0x42bed9['params']['id'],'sectionId':_[_0x7e1d('0x2f')](_0x248fae,function(_0x23892c){return _0x23892c[_0x7e1d('0x5a')];})},'transaction':_0x538596})[_0x7e1d('0x28')](function(){var _0x893c1c=_[_0x7e1d('0x2f')](_0x248fae,function(_0x1e9d26){_0x1e9d26[_0x7e1d('0x5e')]=_0x42bed9['params']['id'];return _0x1e9d26;});var _0x2948e2=[];return BPromise['each'](_0x893c1c,function(_0x1889a0){return db[_0x7e1d('0x56')][_0x7e1d('0x55')](_0x1889a0,{'include':[{'model':db[_0x7e1d('0x59')],'as':_0x7e1d('0x5b')}],'raw':!![],'transaction':_0x538596})[_0x7e1d('0x28')](function(_0x216e93){_0x2948e2['push'](_0x216e93['get']({'plain':!![]}));});})[_0x7e1d('0x28')](function(){return _0x2948e2;});});});}})[_0x7e1d('0x28')](function(_0x7b943){return _0x7b943;})[_0x7e1d('0x28')](respondWithResult(_0x2ac2e1,null))[_0x7e1d('0x48')](handleError(_0x2ac2e1,null));};exports[_0x7e1d('0x5f')]=function(_0x20bdce,_0x476622){var _0x270a75;return db[_0x7e1d('0x30')]['find']({'where':{'id':_0x20bdce['params']['id']},'attributes':['id',_0x7e1d('0x2c')]})[_0x7e1d('0x28')](handleEntityNotFound(_0x476622,null))['then'](function(_0x4ac845){if(_0x4ac845){_0x270a75=_0x4ac845;return db[_0x7e1d('0x56')][_0x7e1d('0x27')]({'where':{'userProfileId':_0x20bdce['params']['id'],'sectionId':_0x20bdce['query']['ids']}});}})[_0x7e1d('0x28')](function(){return _0x270a75;})[_0x7e1d('0x28')](respondWithStatusCode(_0x476622,null))['catch'](handleError(_0x476622,null));};exports[_0x7e1d('0x60')]=function(_0x303fd7,_0x44347c){var _0x4a8f98=[];var _0x18cad1=[];return db['UserProfileSection']['findAll']({'where':{'userProfileId':_0x303fd7[_0x7e1d('0x4a')]['id']},'raw':!![]})[_0x7e1d('0x28')](function(_0x407a05){_0x4a8f98=_['filter'](_0x407a05,function(_0x14259c){return _0x14259c[_0x7e1d('0x61')]===0x1||_[_0x7e1d('0x62')]([0x3eb,0x709],_0x14259c[_0x7e1d('0x5a')]);});if(!_[_0x7e1d('0x63')](_0x4a8f98)){return _[_0x7e1d('0x2f')](_0x4a8f98,function(_0x3211bb){return _0x3211bb[_0x7e1d('0x5a')];});}else{return;}})[_0x7e1d('0x28')](function(_0x5c1b15){if(_0x5c1b15)_0x18cad1=_0x5c1b15;if(_[_0x7e1d('0x62')](_0x18cad1,0x64)){var _0x41e2c7=_[_0x7e1d('0x4b')](_0x4a8f98,{'sectionId':0x64});return hasDefaultDashboard(_0x41e2c7)['then'](function(_0x1bcd88){return _[_0x7e1d('0x2f')](_0x4a8f98,function(_0x3de20f){if(_0x3de20f[_0x7e1d('0x5a')]===0x64){_0x3de20f[_0x7e1d('0x64')]=_0x1bcd88;}return _0x3de20f;});});}else{return;}})[_0x7e1d('0x28')](function(_0x4e9fa9){if(_0x4e9fa9)_0x4a8f98=_0x4e9fa9;if(_[_0x7e1d('0x62')](_0x18cad1,0x3eb)){var _0x306164=_['find'](_0x4a8f98,{'sectionId':0x3eb});return getCustomDashboards(_0x306164)[_0x7e1d('0x28')](function(_0x3c8818){return _[_0x7e1d('0x2f')](_0x4a8f98,function(_0x225658){if(_0x306164[_0x7e1d('0x61')]){if(_0x225658[_0x7e1d('0x5a')]===0x3eb){_0x225658[_0x7e1d('0x64')]=_0x3c8818;}}else{if(_0x225658[_0x7e1d('0x5a')]===0x64){_0x225658[_0x7e1d('0x64')]=_0x3c8818;}}return _0x225658;});});}else{return;}})[_0x7e1d('0x28')](function(_0x229bce){if(_0x229bce)_0x4a8f98=_0x229bce;if(_['includes'](_0x18cad1,0x709)){var _0xb91b72=_[_0x7e1d('0x4b')](_0x4a8f98,{'sectionId':0x709});return getPlugins(_0xb91b72)['then'](function(_0x517a36){if(_0xb91b72[_0x7e1d('0x61')]){return _[_0x7e1d('0x2f')](_0x4a8f98,function(_0x2fba76){if(_0x2fba76['sectionId']===0x709){_0x2fba76[_0x7e1d('0x64')]=_0x517a36;}return _0x2fba76;});}else{var _0x4be476={'sectionId':0x76c,'enabled':0x1,'subsections':_0x517a36};var _0x53e272=_[_0x7e1d('0x2f')](_0x4a8f98);_0x53e272['push'](_0x4be476);return _0x53e272;}});}else{return;}})['then'](function(_0x1870ff){if(_0x1870ff)_0x4a8f98=_0x1870ff;return _[_0x7e1d('0x43')](_0x4a8f98,[_0x7e1d('0x61'),0x1]);})[_0x7e1d('0x28')](respondWithResult(_0x44347c,null))['catch'](handleError(_0x44347c,null));};function hasDefaultDashboard(_0x38a010){var _0x2185b7=[0x65];return new BPromise(function(_0x29b092,_0x24b393){try{if(_0x38a010[_0x7e1d('0x58')]){_0x29b092(_0x2185b7);}else{return db[_0x7e1d('0x59')][_0x7e1d('0x65')]({'where':{'sectionId':_0x38a010['id']},'raw':!![]})[_0x7e1d('0x28')](function(_0x6cfd6b){_0x6cfd6b?_0x29b092(_0x2185b7):_0x29b092();});}}catch(_0x33c0c1){_0x24b393(_0x33c0c1);}});}function getCustomDashboards(_0x4e5e80){var _0x3d3fec=[];return new BPromise(function(_0x2d1987,_0x560310){try{if(_0x4e5e80[_0x7e1d('0x58')]){return db[_0x7e1d('0x66')][_0x7e1d('0x47')]({'raw':!![]})['then'](function(_0x249e63){_0x249e63[_0x7e1d('0x67')](function(_0x34739a){_0x3d3fec[_0x7e1d('0x68')](_0x34739a['id']+0x1869f);});_0x2d1987(_0x3d3fec);});}else{return db['UserProfileResource'][_0x7e1d('0x47')]({'where':{'sectionId':_0x4e5e80['id']},'raw':!![]})[_0x7e1d('0x28')](function(_0x48c6ad){_0x48c6ad['forEach'](function(_0x4fa526){_0x3d3fec[_0x7e1d('0x68')](_0x4fa526[_0x7e1d('0x69')]+0x1869f);});_0x2d1987(_0x3d3fec);});}}catch(_0x40dffc){_0x560310(_0x40dffc);}});}function getPlugins(_0x15afa9){var _0x2afe23=[];return new BPromise(function(_0x97d18f,_0x2034d3){try{if(_0x15afa9[_0x7e1d('0x58')]){return db[_0x7e1d('0x6a')][_0x7e1d('0x47')]({'raw':!![]})[_0x7e1d('0x28')](function(_0x2798dd){_0x2798dd['forEach'](function(_0x4be603){_0x2afe23[_0x7e1d('0x68')](_0x4be603['id']+0x15b38);});_0x97d18f(_0x2afe23);});}else{return db[_0x7e1d('0x59')][_0x7e1d('0x47')]({'where':{'sectionId':_0x15afa9['id']},'raw':!![]})['then'](function(_0x214b03){_0x214b03['forEach'](function(_0x4d1b83){_0x2afe23[_0x7e1d('0x68')](_0x4d1b83[_0x7e1d('0x69')]+0x15b38);});_0x97d18f(_0x2afe23);});}}catch(_0xea0878){_0x2034d3(_0xea0878);}});}exports['addResources']=function(_0x5bb064,_0x1e1126){return db[_0x7e1d('0x30')][_0x7e1d('0x4b')]({'where':{'id':_0x5bb064['params']['id']}})[_0x7e1d('0x28')](handleEntityNotFound(_0x1e1126,null))[_0x7e1d('0x28')](function(_0x75a8ab){if(_0x75a8ab){return db[_0x7e1d('0x53')][_0x7e1d('0x54')](function(_0x4c9980){return db[_0x7e1d('0x56')][_0x7e1d('0x47')]({'where':{'userProfileId':_0x5bb064[_0x7e1d('0x4a')]['id']},'attributes':['id'],'raw':!![]})[_0x7e1d('0x28')](function(_0x2d3fc8){if(_0x2d3fc8){return db['UserProfileSection'][_0x7e1d('0x27')]({'where':{'userProfileId':_0x5bb064[_0x7e1d('0x4a')]['id'],'id':_['map'](_0x2d3fc8,function(_0x4386fb){return _0x4386fb['id'];})},'transaction':_0x4c9980});}})[_0x7e1d('0x28')](function(_0x5881fb){var _0x47d0f5=_[_0x7e1d('0x2f')](_0x5bb064[_0x7e1d('0x4c')],function(_0x4b0c4e){_0x4b0c4e[_0x7e1d('0x5e')]=_0x5bb064[_0x7e1d('0x4a')]['id'];return _0x4b0c4e;});return db[_0x7e1d('0x56')][_0x7e1d('0x6b')](_0x47d0f5,{'raw':!![],'transaction':_0x4c9980});})[_0x7e1d('0x28')](function(_0x1a92ec){var _0x5b0dd0=_[_0x7e1d('0x43')](_[_0x7e1d('0x2f')](_0x1a92ec,function(_0x30bcc2){return _0x30bcc2[_0x7e1d('0x4e')]({'plain':!![]});}),{'includeAll':![]});if(_0x5b0dd0){return db[_0x7e1d('0x56')][_0x7e1d('0x47')]({'where':{'userProfileId':_0x5bb064[_0x7e1d('0x4a')]['id'],'sectionId':_[_0x7e1d('0x2f')](_0x5b0dd0,function(_0x4c6659){return _0x4c6659[_0x7e1d('0x5a')];})},'attributes':['id','sectionId'],'raw':!![]})[_0x7e1d('0x28')](function(_0x16c955){var _0x3caae9=_[_0x7e1d('0x2f')](_0x5bb064['body'],function(_0x49c5de){_0x49c5de['userProfileId']=_0x5bb064['params']['id'];return _0x49c5de;});return db[_0x7e1d('0x59')][_0x7e1d('0x6b')](_0x3caae9,{'raw':!![],'transaction':_0x4c9980});});}})[_0x7e1d('0x48')](handleError(_0x1e1126,null));});}})[_0x7e1d('0x28')](function(_0x32f713){var _0x4f1cae=_[_0x7e1d('0x2f')](_0x32f713,function(_0x3507a4){return _0x3507a4[_0x7e1d('0x4e')]({'plain':!![]});});})[_0x7e1d('0x28')](respondWithResult(_0x1e1126,null))[_0x7e1d('0x48')](handleError(_0x1e1126,null));};exports['removeResources']=function(_0x5bc720,_0x1d8e3e,_0x4dde69){return db['UserProfile'][_0x7e1d('0x4b')]({'where':{'id':_0x5bc720['params']['id']}})['then'](handleEntityNotFound(_0x1d8e3e,null))[_0x7e1d('0x28')](function(_0x254e90){if(_0x254e90){return _0x254e90[_0x7e1d('0x6c')](_0x5bc720[_0x7e1d('0x35')][_0x7e1d('0x6d')]);}})[_0x7e1d('0x28')](respondWithStatusCode(_0x1d8e3e,null))[_0x7e1d('0x48')](handleError(_0x1d8e3e,null));};exports[_0x7e1d('0x6e')]=function(_0x512c38,_0x1163e7){var _0x37d969={};if(!_0x512c38[_0x7e1d('0x35')][_0x7e1d('0x6f')])throw new Error(_0x7e1d('0x70'));if(!_0x512c38[_0x7e1d('0x35')]['hasOwnProperty'](_0x7e1d('0x3c'))){_0x37d969[_0x7e1d('0x20')]=qs['limit'](_0x512c38[_0x7e1d('0x35')]['limit']);_0x37d969[_0x7e1d('0x1e')]=qs[_0x7e1d('0x1e')](_0x512c38[_0x7e1d('0x35')]['offset']);}return db[_0x7e1d('0x30')][_0x7e1d('0x4b')]({'where':{'id':_0x512c38[_0x7e1d('0x4a')]['id']}})['then'](function(_0x4aa222){if(!_0x4aa222)throw new Error(_0x7e1d('0x71')+_0x512c38['params']['id']);return db[_0x7e1d('0x30')][_0x7e1d('0x6e')](_0x512c38);})[_0x7e1d('0x28')](respondWithFilteredResult(_0x1163e7,_0x37d969))[_0x7e1d('0x48')](handleError(_0x1163e7,null));};
\ No newline at end of file
+var _0xcc5f=['No\x20User\x20Profile\x20found\x20for\x20id\x20','rimraf','zip-dir','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','defaults','redis','localhost','socket.io-emitter','./userProfile.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','update','then','destroy','error','stack','name','send','index','map','rawAttributes','fieldName','query','keys','filters','intersection','model','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','type','UserProfile','includeAll','include','rows','catch','show','params','options','find','create','clone','get','omit','createdAt','updatedAt','crudPermissions','body','transaction','UserProfileSection','findAll','each','autoAssociation','UserProfileResource','sectionId','userProfileId','Resources','describe','sequelize','push','ids','getSections','enabled','isEmpty','includes','subsections','concat','findOne','Dashboard','forEach','resourceId','Plugin','addResources','bulkCreate','removeResources','getResources','section','Missing\x20section\x20parameter','hasOwnProperty'];(function(_0x1f1e31,_0x27b5c3){var _0x229b56=function(_0x16db77){while(--_0x16db77){_0x1f1e31['push'](_0x1f1e31['shift']());}};_0x229b56(++_0x27b5c3);}(_0xcc5f,0x157));var _0xfcc5=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xcc5f[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xfcc5('0x0'));var zipdir=require(_0xfcc5('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xfcc5('0x2'));var Mustache=require(_0xfcc5('0x3'));var util=require('util');var path=require(_0xfcc5('0x4'));var sox=require(_0xfcc5('0x5'));var csv=require(_0xfcc5('0x6'));var ejs=require(_0xfcc5('0x7'));var fs=require('fs');var fs_extra=require(_0xfcc5('0x8'));var _=require(_0xfcc5('0x9'));var squel=require(_0xfcc5('0xa'));var crypto=require(_0xfcc5('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xfcc5('0xc'));var toCsv=require(_0xfcc5('0x6'));var querystring=require('querystring');var Papa=require(_0xfcc5('0xd'));var Redis=require(_0xfcc5('0xe'));var authService=require(_0xfcc5('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xfcc5('0x10'));var hardwareService=require(_0xfcc5('0x11'));var logger=require(_0xfcc5('0x12'))(_0xfcc5('0x13'));var utils=require('../../config/utils');var config=require(_0xfcc5('0x14'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config['redis']=_[_0xfcc5('0x15')](config[_0xfcc5('0x16')],{'host':_0xfcc5('0x17'),'port':0x18eb});var socket=require(_0xfcc5('0x18'))(new Redis(config[_0xfcc5('0x16')]));require(_0xfcc5('0x19'))[_0xfcc5('0x1a')](socket);function respondWithStatusCode(_0x3995f3,_0x34756f){_0x34756f=_0x34756f||0xcc;return function(_0x249053){if(_0x249053){return _0x3995f3[_0xfcc5('0x1b')](_0x34756f);}return _0x3995f3[_0xfcc5('0x1c')](_0x34756f)[_0xfcc5('0x1d')]();};}function respondWithResult(_0x36d7d5,_0x3181fd){_0x3181fd=_0x3181fd||0xc8;return function(_0x379329){if(_0x379329){return _0x36d7d5['status'](_0x3181fd)[_0xfcc5('0x1e')](_0x379329);}};}function respondWithFilteredResult(_0x262cac,_0x4ac8e2){return function(_0x587f2f){if(_0x587f2f){var _0x2c6000=typeof _0x4ac8e2[_0xfcc5('0x1f')]===_0xfcc5('0x20')&&typeof _0x4ac8e2[_0xfcc5('0x21')]===_0xfcc5('0x20');var _0x1d2166=_0x587f2f['count'];var _0x373be7=_0x2c6000?0x0:_0x4ac8e2[_0xfcc5('0x1f')];var _0x38e016=_0x2c6000?_0x587f2f[_0xfcc5('0x22')]:_0x4ac8e2[_0xfcc5('0x1f')]+_0x4ac8e2[_0xfcc5('0x21')];var _0x188b9f;if(_0x38e016>=_0x1d2166){_0x38e016=_0x1d2166;_0x188b9f=0xc8;}else{_0x188b9f=0xce;}_0x262cac['status'](_0x188b9f);return _0x262cac['set'](_0xfcc5('0x23'),_0x373be7+'-'+_0x38e016+'/'+_0x1d2166)[_0xfcc5('0x1e')](_0x587f2f);}return null;};}function patchUpdates(_0x3681e1){return function(_0x1e9442){try{jsonpatch[_0xfcc5('0x24')](_0x1e9442,_0x3681e1,!![]);}catch(_0x25f9b8){return BPromise[_0xfcc5('0x25')](_0x25f9b8);}return _0x1e9442['save']();};}function saveUpdates(_0xf5ade,_0x439dbd){return function(_0x52c2d2){if(_0x52c2d2){return _0x52c2d2[_0xfcc5('0x26')](_0xf5ade)[_0xfcc5('0x27')](function(_0x125370){return _0x125370;});}return null;};}function removeEntity(_0x4358a9,_0x3eac25){return function(_0x4f1d1d){if(_0x4f1d1d){return _0x4f1d1d[_0xfcc5('0x28')]()[_0xfcc5('0x27')](function(){_0x4358a9[_0xfcc5('0x1c')](0xcc)[_0xfcc5('0x1d')]();});}};}function handleEntityNotFound(_0x54d662,_0x275ebf){return function(_0x50dbc7){if(!_0x50dbc7){_0x54d662['sendStatus'](0x194);}return _0x50dbc7;};}function handleError(_0x359970,_0x39586b){_0x39586b=_0x39586b||0x1f4;return function(_0x4de8a6){logger[_0xfcc5('0x29')](_0x4de8a6[_0xfcc5('0x2a')]);if(_0x4de8a6[_0xfcc5('0x2b')]){delete _0x4de8a6['name'];}_0x359970['status'](_0x39586b)[_0xfcc5('0x2c')](_0x4de8a6);};}exports[_0xfcc5('0x2d')]=function(_0x96ad60,_0x1911aa){var _0x5b20f4={},_0x377134={},_0xc31737={'count':0x0,'rows':[]};var _0xeec8ee=_[_0xfcc5('0x2e')](db['UserProfile'][_0xfcc5('0x2f')],function(_0x326763){return{'name':_0x326763[_0xfcc5('0x30')],'type':_0x326763['type']['key']};});_0x377134['model']=_['map'](_0xeec8ee,_0xfcc5('0x2b'));_0x377134[_0xfcc5('0x31')]=_[_0xfcc5('0x32')](_0x96ad60['query']);_0x377134[_0xfcc5('0x33')]=_[_0xfcc5('0x34')](_0x377134[_0xfcc5('0x35')],_0x377134[_0xfcc5('0x31')]);_0x5b20f4[_0xfcc5('0x36')]=_[_0xfcc5('0x34')](_0x377134['model'],qs[_0xfcc5('0x37')](_0x96ad60[_0xfcc5('0x31')][_0xfcc5('0x37')]));_0x5b20f4['attributes']=_0x5b20f4[_0xfcc5('0x36')][_0xfcc5('0x38')]?_0x5b20f4[_0xfcc5('0x36')]:_0x377134['model'];if(!_0x96ad60[_0xfcc5('0x31')]['hasOwnProperty'](_0xfcc5('0x39'))){_0x5b20f4[_0xfcc5('0x21')]=qs[_0xfcc5('0x21')](_0x96ad60['query'][_0xfcc5('0x21')]);_0x5b20f4[_0xfcc5('0x1f')]=qs[_0xfcc5('0x1f')](_0x96ad60[_0xfcc5('0x31')]['offset']);}_0x5b20f4[_0xfcc5('0x3a')]=qs['sort'](_0x96ad60[_0xfcc5('0x31')][_0xfcc5('0x3b')]);_0x5b20f4[_0xfcc5('0x3c')]=qs[_0xfcc5('0x33')](_[_0xfcc5('0x3d')](_0x96ad60['query'],_0x377134[_0xfcc5('0x33')]),_0xeec8ee);if(_0x96ad60[_0xfcc5('0x31')][_0xfcc5('0x3e')]){_0x5b20f4[_0xfcc5('0x3c')]=_[_0xfcc5('0x3f')](_0x5b20f4[_0xfcc5('0x3c')],{'$or':_[_0xfcc5('0x2e')](_0xeec8ee,function(_0x483464){if(_0x483464[_0xfcc5('0x40')]!=='VIRTUAL'){var _0x59299f={};_0x59299f[_0x483464[_0xfcc5('0x2b')]]={'$like':'%'+_0x96ad60[_0xfcc5('0x31')][_0xfcc5('0x3e')]+'%'};return _0x59299f;}})});}_0x5b20f4=_[_0xfcc5('0x3f')]({},_0x5b20f4,_0x96ad60['options']);var _0x3a79bb={'where':_0x5b20f4[_0xfcc5('0x3c')]};return db[_0xfcc5('0x41')][_0xfcc5('0x22')](_0x3a79bb)[_0xfcc5('0x27')](function(_0x44a286){_0xc31737[_0xfcc5('0x22')]=_0x44a286;if(_0x96ad60[_0xfcc5('0x31')][_0xfcc5('0x42')]){_0x5b20f4[_0xfcc5('0x43')]=[{'all':!![]}];}return db['UserProfile']['findAll'](_0x5b20f4);})[_0xfcc5('0x27')](function(_0x509bdd){_0xc31737[_0xfcc5('0x44')]=_0x509bdd;return _0xc31737;})[_0xfcc5('0x27')](respondWithFilteredResult(_0x1911aa,_0x5b20f4))[_0xfcc5('0x45')](handleError(_0x1911aa,null));};exports[_0xfcc5('0x46')]=function(_0x45dbc6,_0x50fb63){var _0x29cc67={'raw':![],'where':{'id':_0x45dbc6[_0xfcc5('0x47')]['id']}},_0x129a58={};_0x129a58[_0xfcc5('0x35')]=_[_0xfcc5('0x32')](db['UserProfile'][_0xfcc5('0x2f')]);_0x129a58[_0xfcc5('0x31')]=_[_0xfcc5('0x32')](_0x45dbc6[_0xfcc5('0x31')]);_0x129a58[_0xfcc5('0x33')]=_[_0xfcc5('0x34')](_0x129a58['model'],_0x129a58['query']);_0x29cc67[_0xfcc5('0x36')]=_['intersection'](_0x129a58[_0xfcc5('0x35')],qs[_0xfcc5('0x37')](_0x45dbc6[_0xfcc5('0x31')][_0xfcc5('0x37')]));_0x29cc67[_0xfcc5('0x36')]=_0x29cc67[_0xfcc5('0x36')]['length']?_0x29cc67[_0xfcc5('0x36')]:_0x129a58[_0xfcc5('0x35')];if(_0x45dbc6[_0xfcc5('0x31')][_0xfcc5('0x42')]){_0x29cc67[_0xfcc5('0x43')]=[{'all':!![]}];}_0x29cc67=_[_0xfcc5('0x3f')]({},_0x29cc67,_0x45dbc6[_0xfcc5('0x48')]);return db[_0xfcc5('0x41')][_0xfcc5('0x49')](_0x29cc67)[_0xfcc5('0x27')](handleEntityNotFound(_0x50fb63,null))[_0xfcc5('0x27')](respondWithResult(_0x50fb63,null))[_0xfcc5('0x45')](handleError(_0x50fb63,null));};exports['create']=function(_0x5927a1,_0x3643e2){return db[_0xfcc5('0x41')][_0xfcc5('0x4a')](_0x5927a1['body'],{})[_0xfcc5('0x27')](respondWithResult(_0x3643e2,0xc9))['catch'](handleError(_0x3643e2,null));};exports[_0xfcc5('0x4b')]=function(_0x5c9a9b,_0x16efaf){var _0x2d6216={'where':{'id':_0x5c9a9b['params']['id']}},_0x4538f8={};_0x4538f8['model']=_['keys'](db['UserProfile'][_0xfcc5('0x2f')]);_0x2d6216[_0xfcc5('0x36')]=_[_0xfcc5('0x34')](_0x4538f8[_0xfcc5('0x35')],qs[_0xfcc5('0x37')](_0x5c9a9b[_0xfcc5('0x31')]['fields']));_0x2d6216['attributes']=_0x2d6216[_0xfcc5('0x36')][_0xfcc5('0x38')]?_0x2d6216[_0xfcc5('0x36')]:_0x4538f8[_0xfcc5('0x35')];if(_0x5c9a9b['query'][_0xfcc5('0x42')]){_0x2d6216['include']=[{'all':!![]}];}_0x2d6216=_[_0xfcc5('0x3f')]({},_0x2d6216,_0x5c9a9b[_0xfcc5('0x48')]);return db['UserProfile'][_0xfcc5('0x49')](_0x2d6216)[_0xfcc5('0x27')](handleEntityNotFound(_0x16efaf,null))[_0xfcc5('0x27')](function(_0x373e12){if(_0x373e12){var _0x5048f3=_0x373e12[_0xfcc5('0x4c')]({'plain':!![]});_0x5048f3=qs[_0xfcc5('0x4d')](_0x5048f3,['id',_0xfcc5('0x4e'),_0xfcc5('0x4f'),_0xfcc5('0x50')]);_0x5c9a9b[_0xfcc5('0x51')]=_[_0xfcc5('0x4d')](_0x5c9a9b[_0xfcc5('0x51')],['id',_0xfcc5('0x4e'),'updatedAt']);return db['sequelize'][_0xfcc5('0x52')](function(_0x32e8c9){return db[_0xfcc5('0x41')][_0xfcc5('0x4a')](_[_0xfcc5('0x3f')](_0x5048f3,_0x5c9a9b[_0xfcc5('0x51')]),{'include':_0x5c9a9b['query'][_0xfcc5('0x42')]?[{'all':!![]}]:undefined,'transaction':_0x32e8c9})[_0xfcc5('0x27')](function(_0x5b98b2){var _0xe71ce2=_0x5b98b2[_0xfcc5('0x4c')]({'plain':!![]});return db[_0xfcc5('0x53')][_0xfcc5('0x54')]({'where':{'userProfileId':_0x5c9a9b[_0xfcc5('0x47')]['id']},'raw':!![]})[_0xfcc5('0x27')](function(_0x1ee504){if(_0x1ee504){return BPromise[_0xfcc5('0x55')](_0x1ee504,function(_0x33a757){return new BPromise(function(_0x4b8d93,_0x4bd749){if(_0x33a757['autoAssociation']===null||_0x33a757[_0xfcc5('0x56')]===0x1)_0x4b8d93(null);return db[_0xfcc5('0x57')]['findAll']({'where':{'sectionId':_0x33a757['id']},'raw':!![]})[_0xfcc5('0x27')](function(_0x526495){var _0x4e289a=_['map'](_0x526495,function(_0x7dc798){return qs[_0xfcc5('0x4d')](_0x7dc798,['id',_0xfcc5('0x4e'),_0xfcc5('0x4f'),_0xfcc5('0x58')]);});_0x4b8d93(_0x4e289a);})[_0xfcc5('0x45')](function(_0x572612){_0x4bd749(_0x572612);});})['then'](function(_0x39ef87){var _0x10c422=qs[_0xfcc5('0x4d')](_0x33a757,['id',_0xfcc5('0x4e'),_0xfcc5('0x4f')]);_0x10c422[_0xfcc5('0x59')]=_0xe71ce2['id'];if(_0x39ef87)_0x10c422[_0xfcc5('0x5a')]=_0x39ef87;return _0x10c422;})[_0xfcc5('0x27')](function(_0x3017cd){return db[_0xfcc5('0x53')][_0xfcc5('0x4a')](_0x3017cd,{'include':[{'model':db[_0xfcc5('0x57')],'as':_0xfcc5('0x5a')}],'raw':!![],'transaction':_0x32e8c9});});})[_0xfcc5('0x27')](function(){return _0xe71ce2;});}});});});}})[_0xfcc5('0x27')](respondWithResult(_0x16efaf,0xc9))[_0xfcc5('0x45')](handleError(_0x16efaf,null));};exports[_0xfcc5('0x26')]=function(_0x57ea56,_0x469032){if(_0x57ea56[_0xfcc5('0x51')]['id']){delete _0x57ea56[_0xfcc5('0x51')]['id'];}return db[_0xfcc5('0x41')][_0xfcc5('0x49')]({'where':{'id':_0x57ea56[_0xfcc5('0x47')]['id']}})['then'](handleEntityNotFound(_0x469032,null))['then'](saveUpdates(_0x57ea56['body'],null))[_0xfcc5('0x27')](respondWithResult(_0x469032,null))['catch'](handleError(_0x469032,null));};exports[_0xfcc5('0x28')]=function(_0x11ac5b,_0x2a7e4b){return db[_0xfcc5('0x41')][_0xfcc5('0x49')]({'where':{'id':_0x11ac5b['params']['id']}})[_0xfcc5('0x27')](handleEntityNotFound(_0x2a7e4b,null))['then'](removeEntity(_0x2a7e4b,null))[_0xfcc5('0x45')](handleError(_0x2a7e4b,null));};exports[_0xfcc5('0x5b')]=function(_0x133c42,_0x83e313){return db[_0xfcc5('0x41')]['describe']()['then'](respondWithResult(_0x83e313,null))['catch'](handleError(_0x83e313,null));};exports['addSections']=function(_0x3c9662,_0xc7b19){var _0x28c86a=_0x3c9662[_0xfcc5('0x51')];return db['UserProfile'][_0xfcc5('0x49')]({'where':{'id':_0x3c9662[_0xfcc5('0x47')]['id']}})[_0xfcc5('0x27')](handleEntityNotFound(_0xc7b19,null))[_0xfcc5('0x27')](function(_0x4bc1a0){if(_0x4bc1a0){return db[_0xfcc5('0x5c')]['transaction'](function(_0x17ea5f){return db[_0xfcc5('0x53')][_0xfcc5('0x28')]({'where':{'userProfileId':_0x3c9662[_0xfcc5('0x47')]['id'],'sectionId':_[_0xfcc5('0x2e')](_0x28c86a,function(_0x2c82f0){return _0x2c82f0[_0xfcc5('0x58')];})},'transaction':_0x17ea5f})[_0xfcc5('0x27')](function(){var _0x37ecb2=_[_0xfcc5('0x2e')](_0x28c86a,function(_0x3d8046){_0x3d8046[_0xfcc5('0x59')]=_0x3c9662[_0xfcc5('0x47')]['id'];return _0x3d8046;});var _0x4e1f9d=[];return BPromise[_0xfcc5('0x55')](_0x37ecb2,function(_0x5aae9c){return db[_0xfcc5('0x53')][_0xfcc5('0x4a')](_0x5aae9c,{'include':[{'model':db[_0xfcc5('0x57')],'as':_0xfcc5('0x5a')}],'raw':!![],'transaction':_0x17ea5f})['then'](function(_0x576d16){_0x4e1f9d[_0xfcc5('0x5d')](_0x576d16[_0xfcc5('0x4c')]({'plain':!![]}));});})['then'](function(){return _0x4e1f9d;});});});}})[_0xfcc5('0x27')](function(_0x38a506){return _0x38a506;})[_0xfcc5('0x27')](respondWithResult(_0xc7b19,null))['catch'](handleError(_0xc7b19,null));};exports['removeSections']=function(_0x24926d,_0x24d701){var _0x1a25c9;return db[_0xfcc5('0x41')]['find']({'where':{'id':_0x24926d['params']['id']},'attributes':['id',_0xfcc5('0x2b')]})[_0xfcc5('0x27')](handleEntityNotFound(_0x24d701,null))[_0xfcc5('0x27')](function(_0x3810da){if(_0x3810da){_0x1a25c9=_0x3810da;return db['UserProfileSection'][_0xfcc5('0x28')]({'where':{'userProfileId':_0x24926d['params']['id'],'sectionId':_0x24926d[_0xfcc5('0x31')][_0xfcc5('0x5e')]}});}})[_0xfcc5('0x27')](function(){return _0x1a25c9;})['then'](respondWithStatusCode(_0x24d701,null))[_0xfcc5('0x45')](handleError(_0x24d701,null));};exports[_0xfcc5('0x5f')]=function(_0x22445a,_0x11f6c0){var _0x7fc3b5=[];var _0x37e8e8=[];return db[_0xfcc5('0x53')][_0xfcc5('0x54')]({'where':{'userProfileId':_0x22445a[_0xfcc5('0x47')]['id']},'raw':!![]})[_0xfcc5('0x27')](function(_0x21db50){_0x7fc3b5=_['filter'](_0x21db50,function(_0x380f09){return _0x380f09[_0xfcc5('0x60')]===0x1||_['includes']([0x3eb,0x709],_0x380f09[_0xfcc5('0x58')]);});if(!_[_0xfcc5('0x61')](_0x7fc3b5)){return _[_0xfcc5('0x2e')](_0x7fc3b5,function(_0x1e9e26){return _0x1e9e26[_0xfcc5('0x58')];});}else{return;}})[_0xfcc5('0x27')](function(_0x41ff6d){if(_0x41ff6d)_0x37e8e8=_0x41ff6d;if(_[_0xfcc5('0x62')](_0x37e8e8,0x64)){var _0x37f495=_[_0xfcc5('0x49')](_0x7fc3b5,{'sectionId':0x64});return hasDefaultDashboard(_0x37f495)[_0xfcc5('0x27')](function(_0x50ccf1){return _[_0xfcc5('0x2e')](_0x7fc3b5,function(_0x38da42){if(_0x38da42[_0xfcc5('0x58')]===0x64){_0x38da42[_0xfcc5('0x63')]=_0x50ccf1;}return _0x38da42;});});}else{return;}})[_0xfcc5('0x27')](function(_0x130869){if(_0x130869)_0x7fc3b5=_0x130869;if(_[_0xfcc5('0x62')](_0x37e8e8,0x3eb)){var _0xbd9835=_[_0xfcc5('0x49')](_0x7fc3b5,{'sectionId':0x3eb});return getCustomDashboards(_0xbd9835)['then'](function(_0x2ab5a9){return _['map'](_0x7fc3b5,function(_0x2daa41){if(_0xbd9835[_0xfcc5('0x60')]){if(_0x2daa41[_0xfcc5('0x58')]===0x3eb){_0x2daa41['subsections']=_0x2ab5a9;}}else{if(_0x2daa41[_0xfcc5('0x58')]===0x64){if(!_0x2daa41[_0xfcc5('0x63')]){_0x2daa41[_0xfcc5('0x63')]=[];}_0x2daa41[_0xfcc5('0x63')]=_0x2daa41[_0xfcc5('0x63')][_0xfcc5('0x64')](_0x2ab5a9);}}return _0x2daa41;});});}else{return;}})[_0xfcc5('0x27')](function(_0x596a3f){if(_0x596a3f)_0x7fc3b5=_0x596a3f;if(_['includes'](_0x37e8e8,0x709)){var _0x1772d6=_[_0xfcc5('0x49')](_0x7fc3b5,{'sectionId':0x709});return getPlugins(_0x1772d6)['then'](function(_0x21ed46){if(_0x1772d6['enabled']){return _[_0xfcc5('0x2e')](_0x7fc3b5,function(_0x3a95c3){if(_0x3a95c3[_0xfcc5('0x58')]===0x709){_0x3a95c3[_0xfcc5('0x63')]=_0x21ed46;}return _0x3a95c3;});}else{var _0x2e7ca9={'sectionId':0x76c,'enabled':0x1,'subsections':_0x21ed46};var _0x19b0d9=_[_0xfcc5('0x2e')](_0x7fc3b5);_0x19b0d9[_0xfcc5('0x5d')](_0x2e7ca9);return _0x19b0d9;}});}else{return;}})[_0xfcc5('0x27')](function(_0x53b511){if(_0x53b511)_0x7fc3b5=_0x53b511;return _[_0xfcc5('0x3e')](_0x7fc3b5,[_0xfcc5('0x60'),0x1]);})['then'](respondWithResult(_0x11f6c0,null))[_0xfcc5('0x45')](handleError(_0x11f6c0,null));};function hasDefaultDashboard(_0x500c89){var _0x2a2fd7=[0x65];return new BPromise(function(_0x5186c2,_0x29dd01){try{if(_0x500c89['autoAssociation']){_0x5186c2(_0x2a2fd7);}else{return db[_0xfcc5('0x57')][_0xfcc5('0x65')]({'where':{'sectionId':_0x500c89['id']},'raw':!![]})[_0xfcc5('0x27')](function(_0x34126c){_0x34126c?_0x5186c2(_0x2a2fd7):_0x5186c2();});}}catch(_0x38e2b6){_0x29dd01(_0x38e2b6);}});}function getCustomDashboards(_0x210c7d){var _0x447db7=[];return new BPromise(function(_0x5eeb98,_0x1be62e){try{if(_0x210c7d[_0xfcc5('0x56')]){return db[_0xfcc5('0x66')][_0xfcc5('0x54')]({'raw':!![]})[_0xfcc5('0x27')](function(_0x33ca9a){_0x33ca9a[_0xfcc5('0x67')](function(_0x567893){_0x447db7[_0xfcc5('0x5d')](_0x567893['id']+0x1869f);});_0x5eeb98(_0x447db7);});}else{return db[_0xfcc5('0x57')][_0xfcc5('0x54')]({'where':{'sectionId':_0x210c7d['id']},'raw':!![]})[_0xfcc5('0x27')](function(_0x570b49){_0x570b49['forEach'](function(_0x4dee22){_0x447db7[_0xfcc5('0x5d')](_0x4dee22[_0xfcc5('0x68')]+0x1869f);});_0x5eeb98(_0x447db7);});}}catch(_0x33cf61){_0x1be62e(_0x33cf61);}});}function getPlugins(_0x1907bd){var _0x1f525d=[];return new BPromise(function(_0x3fddc3,_0x4a1750){try{if(_0x1907bd['autoAssociation']){return db[_0xfcc5('0x69')][_0xfcc5('0x54')]({'raw':!![]})[_0xfcc5('0x27')](function(_0xfeea97){_0xfeea97['forEach'](function(_0x54dcf1){_0x1f525d[_0xfcc5('0x5d')](_0x54dcf1['id']+0x15b38);});_0x3fddc3(_0x1f525d);});}else{return db['UserProfileResource'][_0xfcc5('0x54')]({'where':{'sectionId':_0x1907bd['id']},'raw':!![]})[_0xfcc5('0x27')](function(_0x350ed8){_0x350ed8[_0xfcc5('0x67')](function(_0xfafbf1){_0x1f525d['push'](_0xfafbf1[_0xfcc5('0x68')]+0x15b38);});_0x3fddc3(_0x1f525d);});}}catch(_0x53feff){_0x4a1750(_0x53feff);}});}exports[_0xfcc5('0x6a')]=function(_0x501f3f,_0x41311d){return db[_0xfcc5('0x41')][_0xfcc5('0x49')]({'where':{'id':_0x501f3f[_0xfcc5('0x47')]['id']}})[_0xfcc5('0x27')](handleEntityNotFound(_0x41311d,null))['then'](function(_0x333902){if(_0x333902){return db[_0xfcc5('0x5c')][_0xfcc5('0x52')](function(_0x5de4e9){return db[_0xfcc5('0x53')]['findAll']({'where':{'userProfileId':_0x501f3f[_0xfcc5('0x47')]['id']},'attributes':['id'],'raw':!![]})[_0xfcc5('0x27')](function(_0x109056){if(_0x109056){return db[_0xfcc5('0x53')]['destroy']({'where':{'userProfileId':_0x501f3f['params']['id'],'id':_['map'](_0x109056,function(_0x1fe6ab){return _0x1fe6ab['id'];})},'transaction':_0x5de4e9});}})[_0xfcc5('0x27')](function(_0x246818){var _0x33924c=_[_0xfcc5('0x2e')](_0x501f3f[_0xfcc5('0x51')],function(_0xe21b10){_0xe21b10['userProfileId']=_0x501f3f[_0xfcc5('0x47')]['id'];return _0xe21b10;});return db[_0xfcc5('0x53')][_0xfcc5('0x6b')](_0x33924c,{'raw':!![],'transaction':_0x5de4e9});})['then'](function(_0x44ca91){var _0x2275f0=_[_0xfcc5('0x3e')](_[_0xfcc5('0x2e')](_0x44ca91,function(_0x13e8b9){return _0x13e8b9[_0xfcc5('0x4c')]({'plain':!![]});}),{'includeAll':![]});if(_0x2275f0){return db['UserProfileSection']['findAll']({'where':{'userProfileId':_0x501f3f[_0xfcc5('0x47')]['id'],'sectionId':_[_0xfcc5('0x2e')](_0x2275f0,function(_0x1382f3){return _0x1382f3['sectionId'];})},'attributes':['id',_0xfcc5('0x58')],'raw':!![]})[_0xfcc5('0x27')](function(_0xe92ac7){var _0x20dd4c=_[_0xfcc5('0x2e')](_0x501f3f[_0xfcc5('0x51')],function(_0x5ecf5f){_0x5ecf5f[_0xfcc5('0x59')]=_0x501f3f[_0xfcc5('0x47')]['id'];return _0x5ecf5f;});return db['UserProfileResource'][_0xfcc5('0x6b')](_0x20dd4c,{'raw':!![],'transaction':_0x5de4e9});});}})['catch'](handleError(_0x41311d,null));});}})[_0xfcc5('0x27')](function(_0x1ed9f7){var _0x40ad78=_[_0xfcc5('0x2e')](_0x1ed9f7,function(_0x2abd2a){return _0x2abd2a[_0xfcc5('0x4c')]({'plain':!![]});});})[_0xfcc5('0x27')](respondWithResult(_0x41311d,null))['catch'](handleError(_0x41311d,null));};exports[_0xfcc5('0x6c')]=function(_0x507285,_0x2091e1,_0x411f6f){return db[_0xfcc5('0x41')]['find']({'where':{'id':_0x507285[_0xfcc5('0x47')]['id']}})[_0xfcc5('0x27')](handleEntityNotFound(_0x2091e1,null))['then'](function(_0x40c35f){if(_0x40c35f){return _0x40c35f[_0xfcc5('0x6c')](_0x507285['query'][_0xfcc5('0x5e')]);}})['then'](respondWithStatusCode(_0x2091e1,null))[_0xfcc5('0x45')](handleError(_0x2091e1,null));};exports[_0xfcc5('0x6d')]=function(_0x1b3ba7,_0x590e36){var _0x34c326={};if(!_0x1b3ba7[_0xfcc5('0x31')][_0xfcc5('0x6e')])throw new Error(_0xfcc5('0x6f'));if(!_0x1b3ba7[_0xfcc5('0x31')][_0xfcc5('0x70')](_0xfcc5('0x39'))){_0x34c326['limit']=qs['limit'](_0x1b3ba7['query'][_0xfcc5('0x21')]);_0x34c326[_0xfcc5('0x1f')]=qs[_0xfcc5('0x1f')](_0x1b3ba7[_0xfcc5('0x31')][_0xfcc5('0x1f')]);}return db[_0xfcc5('0x41')][_0xfcc5('0x49')]({'where':{'id':_0x1b3ba7[_0xfcc5('0x47')]['id']}})[_0xfcc5('0x27')](function(_0x748aa9){if(!_0x748aa9)throw new Error(_0xfcc5('0x71')+_0x1b3ba7[_0xfcc5('0x47')]['id']);return db[_0xfcc5('0x41')][_0xfcc5('0x6d')](_0x1b3ba7);})[_0xfcc5('0x27')](respondWithFilteredResult(_0x590e36,_0x34c326))['catch'](handleError(_0x590e36,null));};
\ No newline at end of file