Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / api / userProfile / userProfile.controller.js
index fc28691..443892d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf17b=['offset','set','Content-Range','apply','reject','save','update','then','destroy','name','send','map','UserProfile','rawAttributes','fieldName','model','query','attributes','fields','length','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','catch','keys','intersection','options','find','create','body','clone','params','get','omit','createdAt','crudPermissions','sequelize','transaction','UserProfileSection','autoAssociation','updatedAt','userProfileId','Resources','describe','addSections','sectionId','each','UserProfileResource','push','removeSections','ids','getSections','enabled','includes','isEmpty','subsections','findOne','Dashboard','forEach','resourceId','addResources','bulkCreate','removeResources','getResources','Missing\x20section\x20parameter','No\x20User\x20Profile\x20found\x20for\x20id\x20','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','sox','to-csv','fs-extra','crypto','querystring','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','./userProfile.socket','register','status','end','json','limit','undefined','count'];(function(_0x1eae54,_0x4ad8d1){var _0x16f10f=function(_0x447880){while(--_0x447880){_0x1eae54['push'](_0x1eae54['shift']());}};_0x16f10f(++_0x4ad8d1);}(_0xf17b,0x187));var _0xbf17=function(_0x2474ac,_0x335d3a){_0x2474ac=_0x2474ac-0x0;var _0x384a8f=_0xf17b[_0x2474ac];return _0x384a8f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xbf17('0x0'));var zipdir=require(_0xbf17('0x1'));var jsonpatch=require(_0xbf17('0x2'));var rp=require(_0xbf17('0x3'));var moment=require(_0xbf17('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xbf17('0x5'));var util=require(_0xbf17('0x6'));var path=require('path');var sox=require(_0xbf17('0x7'));var csv=require(_0xbf17('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xbf17('0x9'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xbf17('0xa'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xbf17('0xb'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xbf17('0xc'));var qs=require('../../components/parsers/qs');var as=require(_0xbf17('0xd'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xbf17('0xe'))(_0xbf17('0xf'));var utils=require(_0xbf17('0x10'));var config=require(_0xbf17('0x11'));var licenseUtil=require(_0xbf17('0x12'));var db=require(_0xbf17('0x13'))['db'];config[_0xbf17('0x14')]=_['defaults'](config[_0xbf17('0x14')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xbf17('0x15'))[_0xbf17('0x16')](socket);function respondWithStatusCode(_0x1dd444,_0x44384d){_0x44384d=_0x44384d||0xcc;return function(_0x46cdd0){if(_0x46cdd0){return _0x1dd444['sendStatus'](_0x44384d);}return _0x1dd444[_0xbf17('0x17')](_0x44384d)[_0xbf17('0x18')]();};}function respondWithResult(_0x13adae,_0x514437){_0x514437=_0x514437||0xc8;return function(_0x5de498){if(_0x5de498){return _0x13adae['status'](_0x514437)[_0xbf17('0x19')](_0x5de498);}};}function respondWithFilteredResult(_0x4a497d,_0x13163e){return function(_0x1517b8){if(_0x1517b8){var _0x2c3030=typeof _0x13163e['offset']==='undefined'&&typeof _0x13163e[_0xbf17('0x1a')]===_0xbf17('0x1b');var _0xa29a71=_0x1517b8['count'];var _0x28442a=_0x2c3030?0x0:_0x13163e['offset'];var _0x23dda7=_0x2c3030?_0x1517b8[_0xbf17('0x1c')]:_0x13163e[_0xbf17('0x1d')]+_0x13163e[_0xbf17('0x1a')];var _0x57b819;if(_0x23dda7>=_0xa29a71){_0x23dda7=_0xa29a71;_0x57b819=0xc8;}else{_0x57b819=0xce;}_0x4a497d[_0xbf17('0x17')](_0x57b819);return _0x4a497d[_0xbf17('0x1e')](_0xbf17('0x1f'),_0x28442a+'-'+_0x23dda7+'/'+_0xa29a71)[_0xbf17('0x19')](_0x1517b8);}return null;};}function patchUpdates(_0x345b71){return function(_0x5f30ab){try{jsonpatch[_0xbf17('0x20')](_0x5f30ab,_0x345b71,!![]);}catch(_0x154e3f){return BPromise[_0xbf17('0x21')](_0x154e3f);}return _0x5f30ab[_0xbf17('0x22')]();};}function saveUpdates(_0x1349a0,_0x5d9f7){return function(_0x1325b5){if(_0x1325b5){return _0x1325b5[_0xbf17('0x23')](_0x1349a0)[_0xbf17('0x24')](function(_0x4bbcf1){return _0x4bbcf1;});}return null;};}function removeEntity(_0x5a896e,_0x3a5a06){return function(_0x11d035){if(_0x11d035){return _0x11d035[_0xbf17('0x25')]()[_0xbf17('0x24')](function(){_0x5a896e[_0xbf17('0x17')](0xcc)[_0xbf17('0x18')]();});}};}function handleEntityNotFound(_0x4f92f2,_0x19730){return function(_0xd8d119){if(!_0xd8d119){_0x4f92f2['sendStatus'](0x194);}return _0xd8d119;};}function handleError(_0x1324be,_0x896ba5){_0x896ba5=_0x896ba5||0x1f4;return function(_0x5e8040){logger['error'](_0x5e8040['stack']);if(_0x5e8040[_0xbf17('0x26')]){delete _0x5e8040[_0xbf17('0x26')];}_0x1324be[_0xbf17('0x17')](_0x896ba5)[_0xbf17('0x27')](_0x5e8040);};}exports['index']=function(_0x84daad,_0x406256){var _0x46ba4c={},_0x452ab2={},_0x5dd46d={'count':0x0,'rows':[]};var _0x1bd5a8=_[_0xbf17('0x28')](db[_0xbf17('0x29')][_0xbf17('0x2a')],function(_0x13a086){return{'name':_0x13a086[_0xbf17('0x2b')],'type':_0x13a086['type']['key']};});_0x452ab2[_0xbf17('0x2c')]=_[_0xbf17('0x28')](_0x1bd5a8,_0xbf17('0x26'));_0x452ab2['query']=_['keys'](_0x84daad[_0xbf17('0x2d')]);_0x452ab2['filters']=_['intersection'](_0x452ab2['model'],_0x452ab2[_0xbf17('0x2d')]);_0x46ba4c[_0xbf17('0x2e')]=_['intersection'](_0x452ab2[_0xbf17('0x2c')],qs[_0xbf17('0x2f')](_0x84daad['query']['fields']));_0x46ba4c[_0xbf17('0x2e')]=_0x46ba4c['attributes'][_0xbf17('0x30')]?_0x46ba4c['attributes']:_0x452ab2[_0xbf17('0x2c')];if(!_0x84daad[_0xbf17('0x2d')]['hasOwnProperty'](_0xbf17('0x31'))){_0x46ba4c[_0xbf17('0x1a')]=qs['limit'](_0x84daad[_0xbf17('0x2d')][_0xbf17('0x1a')]);_0x46ba4c['offset']=qs[_0xbf17('0x1d')](_0x84daad[_0xbf17('0x2d')]['offset']);}_0x46ba4c[_0xbf17('0x32')]=qs[_0xbf17('0x33')](_0x84daad[_0xbf17('0x2d')]['sort']);_0x46ba4c[_0xbf17('0x34')]=qs[_0xbf17('0x35')](_[_0xbf17('0x36')](_0x84daad['query'],_0x452ab2[_0xbf17('0x35')]),_0x1bd5a8);if(_0x84daad[_0xbf17('0x2d')][_0xbf17('0x37')]){_0x46ba4c[_0xbf17('0x34')]=_[_0xbf17('0x38')](_0x46ba4c['where'],{'$or':_[_0xbf17('0x28')](_0x1bd5a8,function(_0x6927b3){if(_0x6927b3['type']!==_0xbf17('0x39')){var _0x1733d6={};_0x1733d6[_0x6927b3[_0xbf17('0x26')]]={'$like':'%'+_0x84daad[_0xbf17('0x2d')][_0xbf17('0x37')]+'%'};return _0x1733d6;}})});}_0x46ba4c=_[_0xbf17('0x38')]({},_0x46ba4c,_0x84daad['options']);var _0xc227f7={'where':_0x46ba4c[_0xbf17('0x34')]};return db[_0xbf17('0x29')][_0xbf17('0x1c')](_0xc227f7)[_0xbf17('0x24')](function(_0x27d44c){_0x5dd46d[_0xbf17('0x1c')]=_0x27d44c;if(_0x84daad[_0xbf17('0x2d')][_0xbf17('0x3a')]){_0x46ba4c[_0xbf17('0x3b')]=[{'all':!![]}];}return db[_0xbf17('0x29')][_0xbf17('0x3c')](_0x46ba4c);})['then'](function(_0x38bcb7){_0x5dd46d[_0xbf17('0x3d')]=_0x38bcb7;return _0x5dd46d;})[_0xbf17('0x24')](respondWithFilteredResult(_0x406256,_0x46ba4c))[_0xbf17('0x3e')](handleError(_0x406256,null));};exports['show']=function(_0x1d25ed,_0x2423cb){var _0x4e5457={'raw':![],'where':{'id':_0x1d25ed['params']['id']}},_0x4dbc01={};_0x4dbc01[_0xbf17('0x2c')]=_[_0xbf17('0x3f')](db['UserProfile']['rawAttributes']);_0x4dbc01[_0xbf17('0x2d')]=_[_0xbf17('0x3f')](_0x1d25ed[_0xbf17('0x2d')]);_0x4dbc01['filters']=_[_0xbf17('0x40')](_0x4dbc01['model'],_0x4dbc01[_0xbf17('0x2d')]);_0x4e5457[_0xbf17('0x2e')]=_[_0xbf17('0x40')](_0x4dbc01[_0xbf17('0x2c')],qs[_0xbf17('0x2f')](_0x1d25ed[_0xbf17('0x2d')][_0xbf17('0x2f')]));_0x4e5457[_0xbf17('0x2e')]=_0x4e5457[_0xbf17('0x2e')]['length']?_0x4e5457[_0xbf17('0x2e')]:_0x4dbc01[_0xbf17('0x2c')];if(_0x1d25ed[_0xbf17('0x2d')][_0xbf17('0x3a')]){_0x4e5457[_0xbf17('0x3b')]=[{'all':!![]}];}_0x4e5457=_[_0xbf17('0x38')]({},_0x4e5457,_0x1d25ed[_0xbf17('0x41')]);return db[_0xbf17('0x29')][_0xbf17('0x42')](_0x4e5457)['then'](handleEntityNotFound(_0x2423cb,null))[_0xbf17('0x24')](respondWithResult(_0x2423cb,null))['catch'](handleError(_0x2423cb,null));};exports[_0xbf17('0x43')]=function(_0x18947a,_0x593411){return db['UserProfile'][_0xbf17('0x43')](_0x18947a[_0xbf17('0x44')],{})[_0xbf17('0x24')](respondWithResult(_0x593411,0xc9))[_0xbf17('0x3e')](handleError(_0x593411,null));};exports[_0xbf17('0x45')]=function(_0x5e10b6,_0x363aa1){var _0x41299e={'where':{'id':_0x5e10b6[_0xbf17('0x46')]['id']}},_0x402e21={};_0x402e21[_0xbf17('0x2c')]=_[_0xbf17('0x3f')](db[_0xbf17('0x29')][_0xbf17('0x2a')]);_0x41299e[_0xbf17('0x2e')]=_[_0xbf17('0x40')](_0x402e21[_0xbf17('0x2c')],qs[_0xbf17('0x2f')](_0x5e10b6[_0xbf17('0x2d')][_0xbf17('0x2f')]));_0x41299e['attributes']=_0x41299e[_0xbf17('0x2e')]['length']?_0x41299e['attributes']:_0x402e21[_0xbf17('0x2c')];if(_0x5e10b6[_0xbf17('0x2d')]['includeAll']){_0x41299e[_0xbf17('0x3b')]=[{'all':!![]}];}_0x41299e=_[_0xbf17('0x38')]({},_0x41299e,_0x5e10b6[_0xbf17('0x41')]);return db[_0xbf17('0x29')][_0xbf17('0x42')](_0x41299e)[_0xbf17('0x24')](handleEntityNotFound(_0x363aa1,null))['then'](function(_0x14e362){if(_0x14e362){var _0x8ee991=_0x14e362[_0xbf17('0x47')]({'plain':!![]});_0x8ee991=qs[_0xbf17('0x48')](_0x8ee991,['id',_0xbf17('0x49'),'updatedAt',_0xbf17('0x4a')]);_0x5e10b6[_0xbf17('0x44')]=_[_0xbf17('0x48')](_0x5e10b6['body'],['id','createdAt','updatedAt']);return db[_0xbf17('0x4b')][_0xbf17('0x4c')](function(_0x52d7a3){return db['UserProfile'][_0xbf17('0x43')](_[_0xbf17('0x38')](_0x8ee991,_0x5e10b6['body']),{'include':_0x5e10b6[_0xbf17('0x2d')][_0xbf17('0x3a')]?[{'all':!![]}]:undefined,'transaction':_0x52d7a3})[_0xbf17('0x24')](function(_0x2b78b6){var _0x33e7be=_0x2b78b6['get']({'plain':!![]});return db[_0xbf17('0x4d')][_0xbf17('0x3c')]({'where':{'userProfileId':_0x5e10b6['params']['id']},'raw':!![]})[_0xbf17('0x24')](function(_0xc33e72){if(_0xc33e72){return BPromise['each'](_0xc33e72,function(_0x1a20bd){return new BPromise(function(_0x174fec,_0x4ce7c7){if(_0x1a20bd[_0xbf17('0x4e')]===null||_0x1a20bd[_0xbf17('0x4e')]===0x1)_0x174fec(null);return db['UserProfileResource'][_0xbf17('0x3c')]({'where':{'sectionId':_0x1a20bd['id']},'raw':!![]})[_0xbf17('0x24')](function(_0x5580fe){var _0x30fcf3=_[_0xbf17('0x28')](_0x5580fe,function(_0x2e6bef){return qs[_0xbf17('0x48')](_0x2e6bef,['id',_0xbf17('0x49'),_0xbf17('0x4f'),'sectionId']);});_0x174fec(_0x30fcf3);})[_0xbf17('0x3e')](function(_0x403bf1){_0x4ce7c7(_0x403bf1);});})['then'](function(_0x2b74ee){var _0x610a9c=qs['omit'](_0x1a20bd,['id','createdAt','updatedAt']);_0x610a9c[_0xbf17('0x50')]=_0x33e7be['id'];if(_0x2b74ee)_0x610a9c[_0xbf17('0x51')]=_0x2b74ee;return _0x610a9c;})[_0xbf17('0x24')](function(_0x3b171e){return db[_0xbf17('0x4d')][_0xbf17('0x43')](_0x3b171e,{'include':[{'model':db['UserProfileResource'],'as':_0xbf17('0x51')}],'raw':!![],'transaction':_0x52d7a3});});})[_0xbf17('0x24')](function(){return _0x33e7be;});}});});});}})['then'](respondWithResult(_0x363aa1,0xc9))[_0xbf17('0x3e')](handleError(_0x363aa1,null));};exports[_0xbf17('0x23')]=function(_0x22d5a1,_0x21f77a){if(_0x22d5a1['body']['id']){delete _0x22d5a1[_0xbf17('0x44')]['id'];}return db[_0xbf17('0x29')][_0xbf17('0x42')]({'where':{'id':_0x22d5a1[_0xbf17('0x46')]['id']}})[_0xbf17('0x24')](handleEntityNotFound(_0x21f77a,null))[_0xbf17('0x24')](saveUpdates(_0x22d5a1[_0xbf17('0x44')],null))[_0xbf17('0x24')](respondWithResult(_0x21f77a,null))['catch'](handleError(_0x21f77a,null));};exports[_0xbf17('0x25')]=function(_0xeaff0e,_0x11b39f){return db['UserProfile'][_0xbf17('0x42')]({'where':{'id':_0xeaff0e[_0xbf17('0x46')]['id']}})[_0xbf17('0x24')](handleEntityNotFound(_0x11b39f,null))[_0xbf17('0x24')](removeEntity(_0x11b39f,null))[_0xbf17('0x3e')](handleError(_0x11b39f,null));};exports['describe']=function(_0x26c9aa,_0x36c66f){return db[_0xbf17('0x29')][_0xbf17('0x52')]()[_0xbf17('0x24')](respondWithResult(_0x36c66f,null))[_0xbf17('0x3e')](handleError(_0x36c66f,null));};exports[_0xbf17('0x53')]=function(_0x1cac4c,_0x524a3a){var _0x51e57c=_0x1cac4c[_0xbf17('0x44')];return db[_0xbf17('0x29')][_0xbf17('0x42')]({'where':{'id':_0x1cac4c[_0xbf17('0x46')]['id']}})['then'](handleEntityNotFound(_0x524a3a,null))[_0xbf17('0x24')](function(_0x2d0e64){if(_0x2d0e64){return db[_0xbf17('0x4b')][_0xbf17('0x4c')](function(_0x30788f){return db[_0xbf17('0x4d')][_0xbf17('0x25')]({'where':{'userProfileId':_0x1cac4c[_0xbf17('0x46')]['id'],'sectionId':_[_0xbf17('0x28')](_0x51e57c,function(_0x59cff7){return _0x59cff7[_0xbf17('0x54')];})},'transaction':_0x30788f})[_0xbf17('0x24')](function(){var _0x5989ab=_[_0xbf17('0x28')](_0x51e57c,function(_0x4c6cf1){_0x4c6cf1[_0xbf17('0x50')]=_0x1cac4c['params']['id'];return _0x4c6cf1;});var _0x2d912b=[];return BPromise[_0xbf17('0x55')](_0x5989ab,function(_0x1ca09f){return db['UserProfileSection'][_0xbf17('0x43')](_0x1ca09f,{'include':[{'model':db[_0xbf17('0x56')],'as':'Resources'}],'raw':!![],'transaction':_0x30788f})['then'](function(_0x1e2016){_0x2d912b[_0xbf17('0x57')](_0x1e2016['get']({'plain':!![]}));});})['then'](function(){return _0x2d912b;});});});}})[_0xbf17('0x24')](function(_0x316fff){return _0x316fff;})[_0xbf17('0x24')](respondWithResult(_0x524a3a,null))[_0xbf17('0x3e')](handleError(_0x524a3a,null));};exports[_0xbf17('0x58')]=function(_0x2a02bf,_0x2da753){var _0x3a448e;return db[_0xbf17('0x29')][_0xbf17('0x42')]({'where':{'id':_0x2a02bf[_0xbf17('0x46')]['id']},'attributes':['id',_0xbf17('0x26')]})['then'](handleEntityNotFound(_0x2da753,null))['then'](function(_0x82129d){if(_0x82129d){_0x3a448e=_0x82129d;return db[_0xbf17('0x4d')]['destroy']({'where':{'userProfileId':_0x2a02bf[_0xbf17('0x46')]['id'],'sectionId':_0x2a02bf[_0xbf17('0x2d')][_0xbf17('0x59')]}});}})[_0xbf17('0x24')](function(){return _0x3a448e;})[_0xbf17('0x24')](respondWithStatusCode(_0x2da753,null))[_0xbf17('0x3e')](handleError(_0x2da753,null));};exports[_0xbf17('0x5a')]=function(_0xcd1d91,_0x4d7002){var _0x448b38=[];var _0x1fd9f6=[];return db[_0xbf17('0x4d')][_0xbf17('0x3c')]({'where':{'userProfileId':_0xcd1d91[_0xbf17('0x46')]['id']},'raw':!![]})['then'](function(_0x3822ad){_0x448b38=_[_0xbf17('0x37')](_0x3822ad,function(_0x5224b0){return _0x5224b0[_0xbf17('0x5b')]===0x1||_[_0xbf17('0x5c')]([0x3eb,0x709],_0x5224b0[_0xbf17('0x54')]);});if(!_[_0xbf17('0x5d')](_0x448b38)){return _['map'](_0x448b38,function(_0x3992bc){return _0x3992bc['sectionId'];});}else{return;}})[_0xbf17('0x24')](function(_0x40a2c0){if(_0x40a2c0)_0x1fd9f6=_0x40a2c0;if(_[_0xbf17('0x5c')](_0x1fd9f6,0x64)){var _0x1870cd=_['find'](_0x448b38,{'sectionId':0x64});return hasDefaultDashboard(_0x1870cd)[_0xbf17('0x24')](function(_0x7ea63c){return _[_0xbf17('0x28')](_0x448b38,function(_0x5b06c5){if(_0x5b06c5[_0xbf17('0x54')]===0x64){_0x5b06c5['subsections']=_0x7ea63c;}return _0x5b06c5;});});}else{return;}})[_0xbf17('0x24')](function(_0x52fe4f){if(_0x52fe4f)_0x448b38=_0x52fe4f;if(_['includes'](_0x1fd9f6,0x3eb)){var _0x1e6262=_[_0xbf17('0x42')](_0x448b38,{'sectionId':0x3eb});return getCustomDashboards(_0x1e6262)[_0xbf17('0x24')](function(_0x545399){return _[_0xbf17('0x28')](_0x448b38,function(_0x58bbd7){if(_0x1e6262[_0xbf17('0x5b')]){if(_0x58bbd7[_0xbf17('0x54')]===0x3eb){_0x58bbd7[_0xbf17('0x5e')]=_0x545399;}}else{if(_0x58bbd7[_0xbf17('0x54')]===0x64){if(!_0x58bbd7['subsections']){_0x58bbd7[_0xbf17('0x5e')]=[];}_0x58bbd7['subsections']=_0x58bbd7[_0xbf17('0x5e')]['concat'](_0x545399);}}return _0x58bbd7;});});}else{return;}})['then'](function(_0x1976f0){if(_0x1976f0)_0x448b38=_0x1976f0;if(_['includes'](_0x1fd9f6,0x709)){var _0x26bc16=_[_0xbf17('0x42')](_0x448b38,{'sectionId':0x709});return getPlugins(_0x26bc16)[_0xbf17('0x24')](function(_0x40a0c9){if(_0x26bc16['enabled']){return _['map'](_0x448b38,function(_0x4b45e0){if(_0x4b45e0[_0xbf17('0x54')]===0x709){_0x4b45e0[_0xbf17('0x5e')]=_0x40a0c9;}return _0x4b45e0;});}else{var _0x890f5c={'sectionId':0x76c,'enabled':0x1,'subsections':_0x40a0c9};var _0x2d8a79=_[_0xbf17('0x28')](_0x448b38);_0x2d8a79[_0xbf17('0x57')](_0x890f5c);return _0x2d8a79;}});}else{return;}})[_0xbf17('0x24')](function(_0x2e9c65){if(_0x2e9c65)_0x448b38=_0x2e9c65;return _[_0xbf17('0x37')](_0x448b38,[_0xbf17('0x5b'),0x1]);})[_0xbf17('0x24')](respondWithResult(_0x4d7002,null))['catch'](handleError(_0x4d7002,null));};function hasDefaultDashboard(_0x30b0ca){var _0x41d19c=[0x65];return new BPromise(function(_0x58c3e4,_0xf3747){try{if(_0x30b0ca[_0xbf17('0x4e')]){_0x58c3e4(_0x41d19c);}else{return db[_0xbf17('0x56')][_0xbf17('0x5f')]({'where':{'sectionId':_0x30b0ca['id']},'raw':!![]})['then'](function(_0x550672){_0x550672?_0x58c3e4(_0x41d19c):_0x58c3e4();});}}catch(_0x5b85c6){_0xf3747(_0x5b85c6);}});}function getCustomDashboards(_0x4fc16d){var _0x27f349=[];return new BPromise(function(_0x999df4,_0x5deb8c){try{if(_0x4fc16d[_0xbf17('0x4e')]){return db[_0xbf17('0x60')]['findAll']({'raw':!![]})[_0xbf17('0x24')](function(_0x4ba917){_0x4ba917['forEach'](function(_0x5d2f34){_0x27f349[_0xbf17('0x57')](_0x5d2f34['id']+0x1869f);});_0x999df4(_0x27f349);});}else{return db[_0xbf17('0x56')][_0xbf17('0x3c')]({'where':{'sectionId':_0x4fc16d['id']},'raw':!![]})[_0xbf17('0x24')](function(_0x300dee){_0x300dee[_0xbf17('0x61')](function(_0x3c161e){_0x27f349['push'](_0x3c161e[_0xbf17('0x62')]+0x1869f);});_0x999df4(_0x27f349);});}}catch(_0x169319){_0x5deb8c(_0x169319);}});}function getPlugins(_0x9ba3ae){var _0x221dd6=[];return new BPromise(function(_0x39ea57,_0x435697){try{if(_0x9ba3ae['autoAssociation']){return db['Plugin']['findAll']({'raw':!![]})[_0xbf17('0x24')](function(_0x17593b){_0x17593b['forEach'](function(_0x1cc317){_0x221dd6['push'](_0x1cc317['id']+0x15b38);});_0x39ea57(_0x221dd6);});}else{return db[_0xbf17('0x56')][_0xbf17('0x3c')]({'where':{'sectionId':_0x9ba3ae['id']},'raw':!![]})['then'](function(_0x4c5a51){_0x4c5a51[_0xbf17('0x61')](function(_0x311704){_0x221dd6[_0xbf17('0x57')](_0x311704['resourceId']+0x15b38);});_0x39ea57(_0x221dd6);});}}catch(_0x6d55d2){_0x435697(_0x6d55d2);}});}exports[_0xbf17('0x63')]=function(_0x77478f,_0x5414d1){return db['UserProfile'][_0xbf17('0x42')]({'where':{'id':_0x77478f[_0xbf17('0x46')]['id']}})[_0xbf17('0x24')](handleEntityNotFound(_0x5414d1,null))['then'](function(_0x257576){if(_0x257576){return db['sequelize']['transaction'](function(_0x57ce8d){return db[_0xbf17('0x4d')][_0xbf17('0x3c')]({'where':{'userProfileId':_0x77478f[_0xbf17('0x46')]['id']},'attributes':['id'],'raw':!![]})['then'](function(_0x364bac){if(_0x364bac){return db[_0xbf17('0x4d')]['destroy']({'where':{'userProfileId':_0x77478f[_0xbf17('0x46')]['id'],'id':_[_0xbf17('0x28')](_0x364bac,function(_0xe6a24f){return _0xe6a24f['id'];})},'transaction':_0x57ce8d});}})[_0xbf17('0x24')](function(_0x43141f){var _0x21c6e0=_[_0xbf17('0x28')](_0x77478f[_0xbf17('0x44')],function(_0x266e97){_0x266e97[_0xbf17('0x50')]=_0x77478f[_0xbf17('0x46')]['id'];return _0x266e97;});return db[_0xbf17('0x4d')]['bulkCreate'](_0x21c6e0,{'raw':!![],'transaction':_0x57ce8d});})[_0xbf17('0x24')](function(_0x3dca55){var _0x4012c2=_[_0xbf17('0x37')](_['map'](_0x3dca55,function(_0x4866ce){return _0x4866ce['get']({'plain':!![]});}),{'includeAll':![]});if(_0x4012c2){return db['UserProfileSection'][_0xbf17('0x3c')]({'where':{'userProfileId':_0x77478f[_0xbf17('0x46')]['id'],'sectionId':_[_0xbf17('0x28')](_0x4012c2,function(_0x503627){return _0x503627[_0xbf17('0x54')];})},'attributes':['id',_0xbf17('0x54')],'raw':!![]})[_0xbf17('0x24')](function(_0x224cc2){var _0x567e03=_[_0xbf17('0x28')](_0x77478f['body'],function(_0x5a92be){_0x5a92be[_0xbf17('0x50')]=_0x77478f[_0xbf17('0x46')]['id'];return _0x5a92be;});return db[_0xbf17('0x56')][_0xbf17('0x64')](_0x567e03,{'raw':!![],'transaction':_0x57ce8d});});}})[_0xbf17('0x3e')](handleError(_0x5414d1,null));});}})['then'](function(_0x3d3828){var _0x813bec=_[_0xbf17('0x28')](_0x3d3828,function(_0x5d9817){return _0x5d9817[_0xbf17('0x47')]({'plain':!![]});});})[_0xbf17('0x24')](respondWithResult(_0x5414d1,null))[_0xbf17('0x3e')](handleError(_0x5414d1,null));};exports[_0xbf17('0x65')]=function(_0xc0c5d4,_0x629b13,_0x137f3f){return db['UserProfile']['find']({'where':{'id':_0xc0c5d4[_0xbf17('0x46')]['id']}})[_0xbf17('0x24')](handleEntityNotFound(_0x629b13,null))[_0xbf17('0x24')](function(_0x31488e){if(_0x31488e){return _0x31488e['removeResources'](_0xc0c5d4[_0xbf17('0x2d')][_0xbf17('0x59')]);}})['then'](respondWithStatusCode(_0x629b13,null))[_0xbf17('0x3e')](handleError(_0x629b13,null));};exports[_0xbf17('0x66')]=function(_0x53ebce,_0x41e9e6){var _0x3ec554={};if(!_0x53ebce[_0xbf17('0x2d')]['section'])throw new Error(_0xbf17('0x67'));if(!_0x53ebce[_0xbf17('0x2d')]['hasOwnProperty'](_0xbf17('0x31'))){_0x3ec554['limit']=qs[_0xbf17('0x1a')](_0x53ebce['query'][_0xbf17('0x1a')]);_0x3ec554[_0xbf17('0x1d')]=qs[_0xbf17('0x1d')](_0x53ebce[_0xbf17('0x2d')]['offset']);}return db[_0xbf17('0x29')][_0xbf17('0x42')]({'where':{'id':_0x53ebce[_0xbf17('0x46')]['id']}})[_0xbf17('0x24')](function(_0x300bea){if(!_0x300bea)throw new Error(_0xbf17('0x68')+_0x53ebce['params']['id']);return db['UserProfile'][_0xbf17('0x66')](_0x53ebce);})[_0xbf17('0x24')](respondWithFilteredResult(_0x41e9e6,_0x3ec554))[_0xbf17('0x3e')](handleError(_0x41e9e6,null));};
\ No newline at end of file
+var _0x0c73=['find','omit','updatedAt','crudPermissions','createdAt','sequelize','transaction','get','UserProfileSection','autoAssociation','sectionId','userProfileId','Resources','UserProfileResource','describe','addSections','each','push','removeSections','ids','isEmpty','includes','subsections','enabled','findOne','Dashboard','forEach','resourceId','Plugin','removeResources','section','Missing\x20section\x20parameter','No\x20User\x20Profile\x20found\x20for\x20id\x20','getResources','eml-format','zip-dir','fast-json-patch','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','register','status','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','end','sendStatus','error','stack','name','send','index','map','rawAttributes','fieldName','type','model','keys','query','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','filters','where','VIRTUAL','filter','merge','UserProfile','includeAll','include','findAll','catch','params','length','options','create','body','clone'];(function(_0x34b167,_0x5bf6b8){var _0x9bcc7a=function(_0x148423){while(--_0x148423){_0x34b167['push'](_0x34b167['shift']());}};_0x9bcc7a(++_0x5bf6b8);}(_0x0c73,0x17e));var _0x30c7=function(_0x4c4da0,_0x3f2083){_0x4c4da0=_0x4c4da0-0x0;var _0x257623=_0x0c73[_0x4c4da0];return _0x257623;};'use strict';var emlformat=require(_0x30c7('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x30c7('0x1'));var jsonpatch=require(_0x30c7('0x2'));var rp=require('request-promise');var moment=require(_0x30c7('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x30c7('0x4'));var util=require(_0x30c7('0x5'));var path=require(_0x30c7('0x6'));var sox=require(_0x30c7('0x7'));var csv=require(_0x30c7('0x8'));var ejs=require(_0x30c7('0x9'));var fs=require('fs');var fs_extra=require(_0x30c7('0xa'));var _=require('lodash');var squel=require(_0x30c7('0xb'));var crypto=require(_0x30c7('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x30c7('0xd'));var toCsv=require(_0x30c7('0x8'));var querystring=require(_0x30c7('0xe'));var Papa=require(_0x30c7('0xf'));var Redis=require(_0x30c7('0x10'));var authService=require(_0x30c7('0x11'));var qs=require(_0x30c7('0x12'));var as=require(_0x30c7('0x13'));var hardwareService=require(_0x30c7('0x14'));var logger=require(_0x30c7('0x15'))(_0x30c7('0x16'));var utils=require(_0x30c7('0x17'));var config=require(_0x30c7('0x18'));var licenseUtil=require(_0x30c7('0x19'));var db=require(_0x30c7('0x1a'))['db'];config[_0x30c7('0x1b')]=_[_0x30c7('0x1c')](config[_0x30c7('0x1b')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x30c7('0x1b')]));require('./userProfile.socket')[_0x30c7('0x1d')](socket);function respondWithStatusCode(_0x52eb47,_0x4f2d95){_0x4f2d95=_0x4f2d95||0xcc;return function(_0x35cc86){if(_0x35cc86){return _0x52eb47['sendStatus'](_0x4f2d95);}return _0x52eb47[_0x30c7('0x1e')](_0x4f2d95)['end']();};}function respondWithResult(_0x481302,_0x386bf0){_0x386bf0=_0x386bf0||0xc8;return function(_0x23e019){if(_0x23e019){return _0x481302['status'](_0x386bf0)[_0x30c7('0x1f')](_0x23e019);}};}function respondWithFilteredResult(_0x8e0b0c,_0x5cd318){return function(_0x2c29e1){if(_0x2c29e1){var _0x5792f8=typeof _0x5cd318['offset']===_0x30c7('0x20')&&typeof _0x5cd318[_0x30c7('0x21')]==='undefined';var _0x45f3be=_0x2c29e1[_0x30c7('0x22')];var _0x1e2ed1=_0x5792f8?0x0:_0x5cd318[_0x30c7('0x23')];var _0x2c83b8=_0x5792f8?_0x2c29e1[_0x30c7('0x22')]:_0x5cd318[_0x30c7('0x23')]+_0x5cd318['limit'];var _0x3ff4ba;if(_0x2c83b8>=_0x45f3be){_0x2c83b8=_0x45f3be;_0x3ff4ba=0xc8;}else{_0x3ff4ba=0xce;}_0x8e0b0c[_0x30c7('0x1e')](_0x3ff4ba);return _0x8e0b0c[_0x30c7('0x24')](_0x30c7('0x25'),_0x1e2ed1+'-'+_0x2c83b8+'/'+_0x45f3be)['json'](_0x2c29e1);}return null;};}function patchUpdates(_0x38e3c2){return function(_0xd2774b){try{jsonpatch[_0x30c7('0x26')](_0xd2774b,_0x38e3c2,!![]);}catch(_0xdc1a90){return BPromise[_0x30c7('0x27')](_0xdc1a90);}return _0xd2774b[_0x30c7('0x28')]();};}function saveUpdates(_0x348ffc,_0x2349e1){return function(_0x2b7164){if(_0x2b7164){return _0x2b7164[_0x30c7('0x29')](_0x348ffc)[_0x30c7('0x2a')](function(_0x3b379b){return _0x3b379b;});}return null;};}function removeEntity(_0x434a53,_0x56fd8a){return function(_0x5cf319){if(_0x5cf319){return _0x5cf319[_0x30c7('0x2b')]()['then'](function(){_0x434a53[_0x30c7('0x1e')](0xcc)[_0x30c7('0x2c')]();});}};}function handleEntityNotFound(_0xfc4b2,_0x7fadcb){return function(_0xdcdd1c){if(!_0xdcdd1c){_0xfc4b2[_0x30c7('0x2d')](0x194);}return _0xdcdd1c;};}function handleError(_0x576b91,_0x5e92d6){_0x5e92d6=_0x5e92d6||0x1f4;return function(_0x18af71){logger[_0x30c7('0x2e')](_0x18af71[_0x30c7('0x2f')]);if(_0x18af71[_0x30c7('0x30')]){delete _0x18af71[_0x30c7('0x30')];}_0x576b91['status'](_0x5e92d6)[_0x30c7('0x31')](_0x18af71);};}exports[_0x30c7('0x32')]=function(_0x13bfe2,_0x43e73f){var _0x163afe={},_0x490654={},_0x35f404={'count':0x0,'rows':[]};var _0x542a09=_[_0x30c7('0x33')](db['UserProfile'][_0x30c7('0x34')],function(_0x27c8dc){return{'name':_0x27c8dc[_0x30c7('0x35')],'type':_0x27c8dc[_0x30c7('0x36')]['key']};});_0x490654[_0x30c7('0x37')]=_['map'](_0x542a09,'name');_0x490654['query']=_[_0x30c7('0x38')](_0x13bfe2[_0x30c7('0x39')]);_0x490654['filters']=_[_0x30c7('0x3a')](_0x490654[_0x30c7('0x37')],_0x490654[_0x30c7('0x39')]);_0x163afe[_0x30c7('0x3b')]=_[_0x30c7('0x3a')](_0x490654['model'],qs[_0x30c7('0x3c')](_0x13bfe2['query'][_0x30c7('0x3c')]));_0x163afe[_0x30c7('0x3b')]=_0x163afe['attributes']['length']?_0x163afe[_0x30c7('0x3b')]:_0x490654['model'];if(!_0x13bfe2['query'][_0x30c7('0x3d')](_0x30c7('0x3e'))){_0x163afe[_0x30c7('0x21')]=qs[_0x30c7('0x21')](_0x13bfe2['query']['limit']);_0x163afe[_0x30c7('0x23')]=qs[_0x30c7('0x23')](_0x13bfe2['query'][_0x30c7('0x23')]);}_0x163afe[_0x30c7('0x3f')]=qs[_0x30c7('0x40')](_0x13bfe2['query'][_0x30c7('0x40')]);_0x163afe['where']=qs['filters'](_[_0x30c7('0x41')](_0x13bfe2[_0x30c7('0x39')],_0x490654[_0x30c7('0x42')]),_0x542a09);if(_0x13bfe2['query']['filter']){_0x163afe[_0x30c7('0x43')]=_['merge'](_0x163afe[_0x30c7('0x43')],{'$or':_[_0x30c7('0x33')](_0x542a09,function(_0x5e5bf1){if(_0x5e5bf1[_0x30c7('0x36')]!==_0x30c7('0x44')){var _0x3589df={};_0x3589df[_0x5e5bf1[_0x30c7('0x30')]]={'$like':'%'+_0x13bfe2[_0x30c7('0x39')][_0x30c7('0x45')]+'%'};return _0x3589df;}})});}_0x163afe=_[_0x30c7('0x46')]({},_0x163afe,_0x13bfe2['options']);var _0x58660d={'where':_0x163afe['where']};return db[_0x30c7('0x47')][_0x30c7('0x22')](_0x58660d)[_0x30c7('0x2a')](function(_0x2f714b){_0x35f404[_0x30c7('0x22')]=_0x2f714b;if(_0x13bfe2[_0x30c7('0x39')][_0x30c7('0x48')]){_0x163afe[_0x30c7('0x49')]=[{'all':!![]}];}return db[_0x30c7('0x47')][_0x30c7('0x4a')](_0x163afe);})[_0x30c7('0x2a')](function(_0x190e86){_0x35f404['rows']=_0x190e86;return _0x35f404;})[_0x30c7('0x2a')](respondWithFilteredResult(_0x43e73f,_0x163afe))[_0x30c7('0x4b')](handleError(_0x43e73f,null));};exports['show']=function(_0x33de47,_0x221eab){var _0x5c061c={'raw':![],'where':{'id':_0x33de47[_0x30c7('0x4c')]['id']}},_0x371242={};_0x371242['model']=_[_0x30c7('0x38')](db[_0x30c7('0x47')][_0x30c7('0x34')]);_0x371242[_0x30c7('0x39')]=_['keys'](_0x33de47[_0x30c7('0x39')]);_0x371242[_0x30c7('0x42')]=_[_0x30c7('0x3a')](_0x371242['model'],_0x371242['query']);_0x5c061c['attributes']=_['intersection'](_0x371242['model'],qs[_0x30c7('0x3c')](_0x33de47[_0x30c7('0x39')][_0x30c7('0x3c')]));_0x5c061c['attributes']=_0x5c061c[_0x30c7('0x3b')][_0x30c7('0x4d')]?_0x5c061c['attributes']:_0x371242[_0x30c7('0x37')];if(_0x33de47[_0x30c7('0x39')][_0x30c7('0x48')]){_0x5c061c[_0x30c7('0x49')]=[{'all':!![]}];}_0x5c061c=_[_0x30c7('0x46')]({},_0x5c061c,_0x33de47[_0x30c7('0x4e')]);return db[_0x30c7('0x47')]['find'](_0x5c061c)[_0x30c7('0x2a')](handleEntityNotFound(_0x221eab,null))[_0x30c7('0x2a')](respondWithResult(_0x221eab,null))[_0x30c7('0x4b')](handleError(_0x221eab,null));};exports[_0x30c7('0x4f')]=function(_0x3ec7c5,_0x126a13){return db[_0x30c7('0x47')][_0x30c7('0x4f')](_0x3ec7c5[_0x30c7('0x50')],{})[_0x30c7('0x2a')](respondWithResult(_0x126a13,0xc9))[_0x30c7('0x4b')](handleError(_0x126a13,null));};exports[_0x30c7('0x51')]=function(_0x518471,_0x17b38d){var _0xb64a93={'where':{'id':_0x518471['params']['id']}},_0x2fc98a={};_0x2fc98a[_0x30c7('0x37')]=_[_0x30c7('0x38')](db['UserProfile'][_0x30c7('0x34')]);_0xb64a93[_0x30c7('0x3b')]=_[_0x30c7('0x3a')](_0x2fc98a[_0x30c7('0x37')],qs[_0x30c7('0x3c')](_0x518471['query'][_0x30c7('0x3c')]));_0xb64a93[_0x30c7('0x3b')]=_0xb64a93[_0x30c7('0x3b')][_0x30c7('0x4d')]?_0xb64a93[_0x30c7('0x3b')]:_0x2fc98a[_0x30c7('0x37')];if(_0x518471[_0x30c7('0x39')][_0x30c7('0x48')]){_0xb64a93[_0x30c7('0x49')]=[{'all':!![]}];}_0xb64a93=_[_0x30c7('0x46')]({},_0xb64a93,_0x518471['options']);return db['UserProfile'][_0x30c7('0x52')](_0xb64a93)[_0x30c7('0x2a')](handleEntityNotFound(_0x17b38d,null))[_0x30c7('0x2a')](function(_0x41674d){if(_0x41674d){var _0x3aa364=_0x41674d['get']({'plain':!![]});_0x3aa364=qs[_0x30c7('0x53')](_0x3aa364,['id','createdAt',_0x30c7('0x54'),_0x30c7('0x55')]);_0x518471[_0x30c7('0x50')]=_[_0x30c7('0x53')](_0x518471[_0x30c7('0x50')],['id',_0x30c7('0x56'),_0x30c7('0x54')]);return db[_0x30c7('0x57')][_0x30c7('0x58')](function(_0x21c5a9){return db[_0x30c7('0x47')][_0x30c7('0x4f')](_['merge'](_0x3aa364,_0x518471[_0x30c7('0x50')]),{'include':_0x518471[_0x30c7('0x39')][_0x30c7('0x48')]?[{'all':!![]}]:undefined,'transaction':_0x21c5a9})['then'](function(_0x15bac6){var _0x200ed1=_0x15bac6[_0x30c7('0x59')]({'plain':!![]});return db[_0x30c7('0x5a')][_0x30c7('0x4a')]({'where':{'userProfileId':_0x518471[_0x30c7('0x4c')]['id']},'raw':!![]})[_0x30c7('0x2a')](function(_0x48d90b){if(_0x48d90b){return BPromise['each'](_0x48d90b,function(_0x2d5d04){return new BPromise(function(_0x4f311a,_0x1dc45b){if(_0x2d5d04['autoAssociation']===null||_0x2d5d04[_0x30c7('0x5b')]===0x1)_0x4f311a(null);return db['UserProfileResource'][_0x30c7('0x4a')]({'where':{'sectionId':_0x2d5d04['id']},'raw':!![]})[_0x30c7('0x2a')](function(_0x18b54b){var _0x126570=_[_0x30c7('0x33')](_0x18b54b,function(_0x123167){return qs[_0x30c7('0x53')](_0x123167,['id','createdAt',_0x30c7('0x54'),_0x30c7('0x5c')]);});_0x4f311a(_0x126570);})[_0x30c7('0x4b')](function(_0x113011){_0x1dc45b(_0x113011);});})[_0x30c7('0x2a')](function(_0x18e1c2){var _0x60fb0=qs[_0x30c7('0x53')](_0x2d5d04,['id','createdAt',_0x30c7('0x54')]);_0x60fb0[_0x30c7('0x5d')]=_0x200ed1['id'];if(_0x18e1c2)_0x60fb0[_0x30c7('0x5e')]=_0x18e1c2;return _0x60fb0;})[_0x30c7('0x2a')](function(_0x262372){return db[_0x30c7('0x5a')][_0x30c7('0x4f')](_0x262372,{'include':[{'model':db[_0x30c7('0x5f')],'as':_0x30c7('0x5e')}],'raw':!![],'transaction':_0x21c5a9});});})['then'](function(){return _0x200ed1;});}});});});}})[_0x30c7('0x2a')](respondWithResult(_0x17b38d,0xc9))['catch'](handleError(_0x17b38d,null));};exports[_0x30c7('0x29')]=function(_0xa7e42c,_0x5ebb32){if(_0xa7e42c[_0x30c7('0x50')]['id']){delete _0xa7e42c['body']['id'];}return db['UserProfile'][_0x30c7('0x52')]({'where':{'id':_0xa7e42c[_0x30c7('0x4c')]['id']}})[_0x30c7('0x2a')](handleEntityNotFound(_0x5ebb32,null))[_0x30c7('0x2a')](saveUpdates(_0xa7e42c['body'],null))['then'](respondWithResult(_0x5ebb32,null))['catch'](handleError(_0x5ebb32,null));};exports[_0x30c7('0x2b')]=function(_0x52feb6,_0x592437){return db[_0x30c7('0x47')]['find']({'where':{'id':_0x52feb6['params']['id']}})['then'](handleEntityNotFound(_0x592437,null))[_0x30c7('0x2a')](removeEntity(_0x592437,null))['catch'](handleError(_0x592437,null));};exports['describe']=function(_0x58b223,_0x58afa6){return db[_0x30c7('0x47')][_0x30c7('0x60')]()[_0x30c7('0x2a')](respondWithResult(_0x58afa6,null))[_0x30c7('0x4b')](handleError(_0x58afa6,null));};exports[_0x30c7('0x61')]=function(_0x31c1f2,_0x525d2c){var _0x5b3a12=_0x31c1f2['body'];return db[_0x30c7('0x47')][_0x30c7('0x52')]({'where':{'id':_0x31c1f2[_0x30c7('0x4c')]['id']}})[_0x30c7('0x2a')](handleEntityNotFound(_0x525d2c,null))[_0x30c7('0x2a')](function(_0x5f3004){if(_0x5f3004){return db[_0x30c7('0x57')][_0x30c7('0x58')](function(_0x2dd0a0){return db['UserProfileSection'][_0x30c7('0x2b')]({'where':{'userProfileId':_0x31c1f2['params']['id'],'sectionId':_['map'](_0x5b3a12,function(_0x31c8db){return _0x31c8db[_0x30c7('0x5c')];})},'transaction':_0x2dd0a0})[_0x30c7('0x2a')](function(){var _0x4a3245=_[_0x30c7('0x33')](_0x5b3a12,function(_0x3220ba){_0x3220ba['userProfileId']=_0x31c1f2['params']['id'];return _0x3220ba;});var _0x42eb50=[];return BPromise[_0x30c7('0x62')](_0x4a3245,function(_0x1f5043){return db[_0x30c7('0x5a')][_0x30c7('0x4f')](_0x1f5043,{'include':[{'model':db[_0x30c7('0x5f')],'as':_0x30c7('0x5e')}],'raw':!![],'transaction':_0x2dd0a0})[_0x30c7('0x2a')](function(_0x194488){_0x42eb50[_0x30c7('0x63')](_0x194488[_0x30c7('0x59')]({'plain':!![]}));});})[_0x30c7('0x2a')](function(){return _0x42eb50;});});});}})[_0x30c7('0x2a')](function(_0x12d1e6){return _0x12d1e6;})[_0x30c7('0x2a')](respondWithResult(_0x525d2c,null))[_0x30c7('0x4b')](handleError(_0x525d2c,null));};exports[_0x30c7('0x64')]=function(_0x3b9cf1,_0x518091){var _0x4ebd0e;return db[_0x30c7('0x47')][_0x30c7('0x52')]({'where':{'id':_0x3b9cf1[_0x30c7('0x4c')]['id']},'attributes':['id',_0x30c7('0x30')]})[_0x30c7('0x2a')](handleEntityNotFound(_0x518091,null))[_0x30c7('0x2a')](function(_0x1a7969){if(_0x1a7969){_0x4ebd0e=_0x1a7969;return db[_0x30c7('0x5a')][_0x30c7('0x2b')]({'where':{'userProfileId':_0x3b9cf1[_0x30c7('0x4c')]['id'],'sectionId':_0x3b9cf1[_0x30c7('0x39')][_0x30c7('0x65')]}});}})[_0x30c7('0x2a')](function(){return _0x4ebd0e;})[_0x30c7('0x2a')](respondWithStatusCode(_0x518091,null))[_0x30c7('0x4b')](handleError(_0x518091,null));};exports['getSections']=function(_0x71a62,_0xf27b59){var _0x5a6228=[];var _0x1cb640=[];return db['UserProfileSection'][_0x30c7('0x4a')]({'where':{'userProfileId':_0x71a62[_0x30c7('0x4c')]['id']},'raw':!![]})[_0x30c7('0x2a')](function(_0x49aa92){_0x5a6228=_[_0x30c7('0x45')](_0x49aa92,function(_0x1d5c98){return _0x1d5c98['enabled']===0x1||_['includes']([0x3eb,0x709],_0x1d5c98[_0x30c7('0x5c')]);});if(!_[_0x30c7('0x66')](_0x5a6228)){return _[_0x30c7('0x33')](_0x5a6228,function(_0x41e7b9){return _0x41e7b9[_0x30c7('0x5c')];});}else{return;}})[_0x30c7('0x2a')](function(_0x452217){if(_0x452217)_0x1cb640=_0x452217;if(_[_0x30c7('0x67')](_0x1cb640,0x64)){var _0x3b348e=_[_0x30c7('0x52')](_0x5a6228,{'sectionId':0x64});return hasDefaultDashboard(_0x3b348e)[_0x30c7('0x2a')](function(_0x47271a){return _[_0x30c7('0x33')](_0x5a6228,function(_0x2730fb){if(_0x2730fb[_0x30c7('0x5c')]===0x64){_0x2730fb[_0x30c7('0x68')]=_0x47271a;}return _0x2730fb;});});}else{return;}})['then'](function(_0x2a0c0a){if(_0x2a0c0a)_0x5a6228=_0x2a0c0a;if(_['includes'](_0x1cb640,0x3eb)){var _0x570ef2=_[_0x30c7('0x52')](_0x5a6228,{'sectionId':0x3eb});return getCustomDashboards(_0x570ef2)[_0x30c7('0x2a')](function(_0x343b8c){return _['map'](_0x5a6228,function(_0x2ceb83){if(_0x570ef2[_0x30c7('0x69')]){if(_0x2ceb83[_0x30c7('0x5c')]===0x3eb){_0x2ceb83[_0x30c7('0x68')]=_0x343b8c;}}else{if(_0x2ceb83[_0x30c7('0x5c')]===0x64){if(!_0x2ceb83[_0x30c7('0x68')]){_0x2ceb83[_0x30c7('0x68')]=[];}_0x2ceb83['subsections']=_0x2ceb83[_0x30c7('0x68')]['concat'](_0x343b8c);}}return _0x2ceb83;});});}else{return;}})[_0x30c7('0x2a')](function(_0x51dbca){if(_0x51dbca)_0x5a6228=_0x51dbca;if(_[_0x30c7('0x67')](_0x1cb640,0x709)){var _0x2cb979=_[_0x30c7('0x52')](_0x5a6228,{'sectionId':0x709});return getPlugins(_0x2cb979)[_0x30c7('0x2a')](function(_0x201c20){if(_0x2cb979['enabled']){return _['map'](_0x5a6228,function(_0x34a8c6){if(_0x34a8c6[_0x30c7('0x5c')]===0x709){_0x34a8c6[_0x30c7('0x68')]=_0x201c20;}return _0x34a8c6;});}else{var _0x22cc22={'sectionId':0x76c,'enabled':0x1,'subsections':_0x201c20};var _0x1b3a5b=_['map'](_0x5a6228);_0x1b3a5b[_0x30c7('0x63')](_0x22cc22);return _0x1b3a5b;}});}else{return;}})[_0x30c7('0x2a')](function(_0x51ae56){if(_0x51ae56)_0x5a6228=_0x51ae56;return _[_0x30c7('0x45')](_0x5a6228,[_0x30c7('0x69'),0x1]);})['then'](respondWithResult(_0xf27b59,null))['catch'](handleError(_0xf27b59,null));};function hasDefaultDashboard(_0x2f915f){var _0x41ae86=[0x65];return new BPromise(function(_0x25b72b,_0x102eb0){try{if(_0x2f915f[_0x30c7('0x5b')]){_0x25b72b(_0x41ae86);}else{return db[_0x30c7('0x5f')][_0x30c7('0x6a')]({'where':{'sectionId':_0x2f915f['id']},'raw':!![]})[_0x30c7('0x2a')](function(_0x2f2009){_0x2f2009?_0x25b72b(_0x41ae86):_0x25b72b();});}}catch(_0x5cbae1){_0x102eb0(_0x5cbae1);}});}function getCustomDashboards(_0x475a21){var _0x276fd4=[];return new BPromise(function(_0x3f1ab6,_0x2c0f75){try{if(_0x475a21[_0x30c7('0x5b')]){return db[_0x30c7('0x6b')][_0x30c7('0x4a')]({'raw':!![]})[_0x30c7('0x2a')](function(_0x1304a4){_0x1304a4['forEach'](function(_0x51bb50){_0x276fd4[_0x30c7('0x63')](_0x51bb50['id']+0x1869f);});_0x3f1ab6(_0x276fd4);});}else{return db[_0x30c7('0x5f')][_0x30c7('0x4a')]({'where':{'sectionId':_0x475a21['id']},'raw':!![]})[_0x30c7('0x2a')](function(_0x154112){_0x154112[_0x30c7('0x6c')](function(_0x4351be){_0x276fd4[_0x30c7('0x63')](_0x4351be[_0x30c7('0x6d')]+0x1869f);});_0x3f1ab6(_0x276fd4);});}}catch(_0x1a389a){_0x2c0f75(_0x1a389a);}});}function getPlugins(_0x19bce6){var _0x43f48e=[];return new BPromise(function(_0x125ee8,_0x302c3f){try{if(_0x19bce6[_0x30c7('0x5b')]){return db[_0x30c7('0x6e')][_0x30c7('0x4a')]({'raw':!![]})['then'](function(_0x5a0c09){_0x5a0c09[_0x30c7('0x6c')](function(_0x2f705d){_0x43f48e[_0x30c7('0x63')](_0x2f705d['id']+0x15b38);});_0x125ee8(_0x43f48e);});}else{return db[_0x30c7('0x5f')]['findAll']({'where':{'sectionId':_0x19bce6['id']},'raw':!![]})['then'](function(_0x9c1d81){_0x9c1d81[_0x30c7('0x6c')](function(_0x457d1b){_0x43f48e[_0x30c7('0x63')](_0x457d1b[_0x30c7('0x6d')]+0x15b38);});_0x125ee8(_0x43f48e);});}}catch(_0x6508d9){_0x302c3f(_0x6508d9);}});}exports['addResources']=function(_0x25c3f6,_0x4da5c9){return db[_0x30c7('0x47')][_0x30c7('0x52')]({'where':{'id':_0x25c3f6['params']['id']}})['then'](handleEntityNotFound(_0x4da5c9,null))['then'](function(_0x1cd856){if(_0x1cd856){return db[_0x30c7('0x57')][_0x30c7('0x58')](function(_0x4498dc){return db['UserProfileSection']['findAll']({'where':{'userProfileId':_0x25c3f6[_0x30c7('0x4c')]['id']},'attributes':['id'],'raw':!![]})[_0x30c7('0x2a')](function(_0x2d3c33){if(_0x2d3c33){return db[_0x30c7('0x5a')][_0x30c7('0x2b')]({'where':{'userProfileId':_0x25c3f6[_0x30c7('0x4c')]['id'],'id':_[_0x30c7('0x33')](_0x2d3c33,function(_0x88abe3){return _0x88abe3['id'];})},'transaction':_0x4498dc});}})[_0x30c7('0x2a')](function(_0x1884d7){var _0x1b9f9b=_[_0x30c7('0x33')](_0x25c3f6['body'],function(_0x493679){_0x493679[_0x30c7('0x5d')]=_0x25c3f6[_0x30c7('0x4c')]['id'];return _0x493679;});return db['UserProfileSection']['bulkCreate'](_0x1b9f9b,{'raw':!![],'transaction':_0x4498dc});})['then'](function(_0x13a64b){var _0x52f073=_[_0x30c7('0x45')](_['map'](_0x13a64b,function(_0x48ec07){return _0x48ec07['get']({'plain':!![]});}),{'includeAll':![]});if(_0x52f073){return db['UserProfileSection'][_0x30c7('0x4a')]({'where':{'userProfileId':_0x25c3f6[_0x30c7('0x4c')]['id'],'sectionId':_[_0x30c7('0x33')](_0x52f073,function(_0x4d55e2){return _0x4d55e2[_0x30c7('0x5c')];})},'attributes':['id',_0x30c7('0x5c')],'raw':!![]})[_0x30c7('0x2a')](function(_0x214544){var _0x39b43a=_['map'](_0x25c3f6['body'],function(_0x39a6d2){_0x39a6d2['userProfileId']=_0x25c3f6[_0x30c7('0x4c')]['id'];return _0x39a6d2;});return db[_0x30c7('0x5f')]['bulkCreate'](_0x39b43a,{'raw':!![],'transaction':_0x4498dc});});}})[_0x30c7('0x4b')](handleError(_0x4da5c9,null));});}})[_0x30c7('0x2a')](function(_0x4327ab){var _0x29ef30=_[_0x30c7('0x33')](_0x4327ab,function(_0x1a345b){return _0x1a345b['get']({'plain':!![]});});})[_0x30c7('0x2a')](respondWithResult(_0x4da5c9,null))[_0x30c7('0x4b')](handleError(_0x4da5c9,null));};exports[_0x30c7('0x6f')]=function(_0x5cdbd7,_0xc796e2,_0x234375){return db[_0x30c7('0x47')][_0x30c7('0x52')]({'where':{'id':_0x5cdbd7[_0x30c7('0x4c')]['id']}})[_0x30c7('0x2a')](handleEntityNotFound(_0xc796e2,null))[_0x30c7('0x2a')](function(_0x5d4802){if(_0x5d4802){return _0x5d4802[_0x30c7('0x6f')](_0x5cdbd7[_0x30c7('0x39')][_0x30c7('0x65')]);}})[_0x30c7('0x2a')](respondWithStatusCode(_0xc796e2,null))['catch'](handleError(_0xc796e2,null));};exports['getResources']=function(_0x11f0a2,_0x1535d0){var _0x4823bb={};if(!_0x11f0a2[_0x30c7('0x39')][_0x30c7('0x70')])throw new Error(_0x30c7('0x71'));if(!_0x11f0a2[_0x30c7('0x39')][_0x30c7('0x3d')](_0x30c7('0x3e'))){_0x4823bb[_0x30c7('0x21')]=qs[_0x30c7('0x21')](_0x11f0a2[_0x30c7('0x39')][_0x30c7('0x21')]);_0x4823bb[_0x30c7('0x23')]=qs[_0x30c7('0x23')](_0x11f0a2[_0x30c7('0x39')][_0x30c7('0x23')]);}return db[_0x30c7('0x47')][_0x30c7('0x52')]({'where':{'id':_0x11f0a2[_0x30c7('0x4c')]['id']}})[_0x30c7('0x2a')](function(_0x2ae891){if(!_0x2ae891)throw new Error(_0x30c7('0x72')+_0x11f0a2[_0x30c7('0x4c')]['id']);return db[_0x30c7('0x47')][_0x30c7('0x73')](_0x11f0a2);})[_0x30c7('0x2a')](respondWithFilteredResult(_0x1535d0,_0x4823bb))[_0x30c7('0x4b')](handleError(_0x1535d0,null));};
\ No newline at end of file