Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / cloudProvider / cloudProvider.controller.js
index 1a02b17..be59f07 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5f66=['update','catch','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','sendStatus','status','end','json','undefined','limit','count','offset','Content-Range','apply','reject','save','destroy','then','error','name','send','index','map','CloudProvider','rawAttributes','fieldName','model','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','filter','merge','type','VIRTUAL','includeAll','include','findAll','rows','show','params','find','create','body'];(function(_0x1efb1e,_0x1a093d){var _0x117e95=function(_0x2de7f7){while(--_0x2de7f7){_0x1efb1e['push'](_0x1efb1e['shift']());}};_0x117e95(++_0x1a093d);}(_0x5f66,0x1a0));var _0x65f6=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0x5f66[_0x3947c9];return _0x2e7871;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x65f6('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x65f6('0x1'));var rp=require(_0x65f6('0x2'));var moment=require(_0x65f6('0x3'));var BPromise=require(_0x65f6('0x4'));var Mustache=require(_0x65f6('0x5'));var util=require('util');var path=require(_0x65f6('0x6'));var sox=require('sox');var csv=require(_0x65f6('0x7'));var ejs=require(_0x65f6('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x65f6('0x9'));var crypto=require(_0x65f6('0xa'));var jsforce=require(_0x65f6('0xb'));var deskjs=require(_0x65f6('0xc'));var toCsv=require(_0x65f6('0x7'));var querystring=require(_0x65f6('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x65f6('0xe'));var qs=require(_0x65f6('0xf'));var as=require(_0x65f6('0x10'));var hardwareService=require(_0x65f6('0x11'));var logger=require('../../config/logger')(_0x65f6('0x12'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x65f6('0x13'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x419819,_0x4862a5){_0x4862a5=_0x4862a5||0xcc;return function(_0x2f964a){if(_0x2f964a){return _0x419819[_0x65f6('0x14')](_0x4862a5);}return _0x419819[_0x65f6('0x15')](_0x4862a5)[_0x65f6('0x16')]();};}function respondWithResult(_0x369f96,_0x1d29fd){_0x1d29fd=_0x1d29fd||0xc8;return function(_0x44144b){if(_0x44144b){return _0x369f96[_0x65f6('0x15')](_0x1d29fd)[_0x65f6('0x17')](_0x44144b);}};}function respondWithFilteredResult(_0x3440af,_0x59154e){return function(_0x19b9ff){if(_0x19b9ff){var _0x49a913=typeof _0x59154e['offset']===_0x65f6('0x18')&&typeof _0x59154e[_0x65f6('0x19')]===_0x65f6('0x18');var _0x1c955c=_0x19b9ff[_0x65f6('0x1a')];var _0x1f974c=_0x49a913?0x0:_0x59154e[_0x65f6('0x1b')];var _0x18380e=_0x49a913?_0x19b9ff['count']:_0x59154e['offset']+_0x59154e[_0x65f6('0x19')];var _0x5b4055;if(_0x18380e>=_0x1c955c){_0x18380e=_0x1c955c;_0x5b4055=0xc8;}else{_0x5b4055=0xce;}_0x3440af['status'](_0x5b4055);return _0x3440af['set'](_0x65f6('0x1c'),_0x1f974c+'-'+_0x18380e+'/'+_0x1c955c)[_0x65f6('0x17')](_0x19b9ff);}return null;};}function patchUpdates(_0x5114a4){return function(_0x39e19f){try{jsonpatch[_0x65f6('0x1d')](_0x39e19f,_0x5114a4,!![]);}catch(_0xbee6a4){return BPromise[_0x65f6('0x1e')](_0xbee6a4);}return _0x39e19f[_0x65f6('0x1f')]();};}function saveUpdates(_0xc139c2,_0x581374){return function(_0x197a49){if(_0x197a49){return _0x197a49['update'](_0xc139c2)['then'](function(_0x212247){return _0x212247;});}return null;};}function removeEntity(_0xd173f4,_0x524e42){return function(_0x1eeaaa){if(_0x1eeaaa){return _0x1eeaaa[_0x65f6('0x20')]()[_0x65f6('0x21')](function(){_0xd173f4[_0x65f6('0x15')](0xcc)['end']();});}};}function handleEntityNotFound(_0x9d7bb0,_0x59ea32){return function(_0x20a161){if(!_0x20a161){_0x9d7bb0['sendStatus'](0x194);}return _0x20a161;};}function handleError(_0x5cb131,_0x4fde2f){_0x4fde2f=_0x4fde2f||0x1f4;return function(_0x29abdb){logger[_0x65f6('0x22')](_0x29abdb['stack']);if(_0x29abdb[_0x65f6('0x23')]){delete _0x29abdb[_0x65f6('0x23')];}_0x5cb131['status'](_0x4fde2f)[_0x65f6('0x24')](_0x29abdb);};}exports[_0x65f6('0x25')]=function(_0x28d0df,_0x559330){var _0x4ac04b={},_0x488d36={},_0x266cfe={'count':0x0,'rows':[]};var _0x3c032f=_[_0x65f6('0x26')](db[_0x65f6('0x27')][_0x65f6('0x28')],function(_0x14a387){return{'name':_0x14a387[_0x65f6('0x29')],'type':_0x14a387['type']['key']};});_0x488d36[_0x65f6('0x2a')]=_[_0x65f6('0x26')](_0x3c032f,'name');_0x488d36['query']=_[_0x65f6('0x2b')](_0x28d0df[_0x65f6('0x2c')]);_0x488d36[_0x65f6('0x2d')]=_[_0x65f6('0x2e')](_0x488d36[_0x65f6('0x2a')],_0x488d36[_0x65f6('0x2c')]);_0x4ac04b['attributes']=_[_0x65f6('0x2e')](_0x488d36[_0x65f6('0x2a')],qs[_0x65f6('0x2f')](_0x28d0df['query'][_0x65f6('0x2f')]));_0x4ac04b[_0x65f6('0x30')]=_0x4ac04b[_0x65f6('0x30')][_0x65f6('0x31')]?_0x4ac04b[_0x65f6('0x30')]:_0x488d36[_0x65f6('0x2a')];if(!_0x28d0df['query'][_0x65f6('0x32')](_0x65f6('0x33'))){_0x4ac04b['limit']=qs[_0x65f6('0x19')](_0x28d0df['query'][_0x65f6('0x19')]);_0x4ac04b['offset']=qs[_0x65f6('0x1b')](_0x28d0df[_0x65f6('0x2c')]['offset']);}_0x4ac04b[_0x65f6('0x34')]=qs[_0x65f6('0x35')](_0x28d0df[_0x65f6('0x2c')]['sort']);_0x4ac04b['where']=qs[_0x65f6('0x2d')](_['pick'](_0x28d0df[_0x65f6('0x2c')],_0x488d36['filters']),_0x3c032f);if(_0x28d0df[_0x65f6('0x2c')][_0x65f6('0x36')]){_0x4ac04b['where']=_[_0x65f6('0x37')](_0x4ac04b['where'],{'$or':_['map'](_0x3c032f,function(_0x71b16b){if(_0x71b16b[_0x65f6('0x38')]!==_0x65f6('0x39')){var _0x313be5={};_0x313be5[_0x71b16b[_0x65f6('0x23')]]={'$like':'%'+_0x28d0df[_0x65f6('0x2c')][_0x65f6('0x36')]+'%'};return _0x313be5;}})});}_0x4ac04b=_[_0x65f6('0x37')]({},_0x4ac04b,_0x28d0df['options']);var _0x3aa254={'where':_0x4ac04b['where']};return db[_0x65f6('0x27')][_0x65f6('0x1a')](_0x3aa254)[_0x65f6('0x21')](function(_0x2ea7f7){_0x266cfe['count']=_0x2ea7f7;if(_0x28d0df[_0x65f6('0x2c')][_0x65f6('0x3a')]){_0x4ac04b[_0x65f6('0x3b')]=[{'all':!![]}];}return db[_0x65f6('0x27')][_0x65f6('0x3c')](_0x4ac04b);})[_0x65f6('0x21')](function(_0xed4c96){_0x266cfe[_0x65f6('0x3d')]=_0xed4c96;return _0x266cfe;})[_0x65f6('0x21')](respondWithFilteredResult(_0x559330,_0x4ac04b))['catch'](handleError(_0x559330,null));};exports[_0x65f6('0x3e')]=function(_0x400ed2,_0x377ae5){var _0x181798={'raw':!![],'where':{'id':_0x400ed2[_0x65f6('0x3f')]['id']}},_0x83e2d9={};_0x83e2d9[_0x65f6('0x2a')]=_[_0x65f6('0x2b')](db[_0x65f6('0x27')][_0x65f6('0x28')]);_0x83e2d9[_0x65f6('0x2c')]=_[_0x65f6('0x2b')](_0x400ed2[_0x65f6('0x2c')]);_0x83e2d9[_0x65f6('0x2d')]=_[_0x65f6('0x2e')](_0x83e2d9[_0x65f6('0x2a')],_0x83e2d9['query']);_0x181798[_0x65f6('0x30')]=_[_0x65f6('0x2e')](_0x83e2d9[_0x65f6('0x2a')],qs[_0x65f6('0x2f')](_0x400ed2['query'][_0x65f6('0x2f')]));_0x181798[_0x65f6('0x30')]=_0x181798[_0x65f6('0x30')]['length']?_0x181798[_0x65f6('0x30')]:_0x83e2d9[_0x65f6('0x2a')];if(_0x400ed2[_0x65f6('0x2c')][_0x65f6('0x3a')]){_0x181798['include']=[{'all':!![]}];}_0x181798=_[_0x65f6('0x37')]({},_0x181798,_0x400ed2['options']);return db[_0x65f6('0x27')][_0x65f6('0x40')](_0x181798)['then'](handleEntityNotFound(_0x377ae5,null))[_0x65f6('0x21')](respondWithResult(_0x377ae5,null))['catch'](handleError(_0x377ae5,null));};exports[_0x65f6('0x41')]=function(_0x4d9b76,_0x2d1706){return db[_0x65f6('0x27')][_0x65f6('0x41')](_0x4d9b76[_0x65f6('0x42')],{})['then'](respondWithResult(_0x2d1706,0xc9))['catch'](handleError(_0x2d1706,null));};exports[_0x65f6('0x43')]=function(_0x15d3ba,_0x3b647a){if(_0x15d3ba[_0x65f6('0x42')]['id']){delete _0x15d3ba[_0x65f6('0x42')]['id'];}return db[_0x65f6('0x27')][_0x65f6('0x40')]({'where':{'id':_0x15d3ba[_0x65f6('0x3f')]['id']}})[_0x65f6('0x21')](handleEntityNotFound(_0x3b647a,null))['then'](saveUpdates(_0x15d3ba[_0x65f6('0x42')],null))[_0x65f6('0x21')](respondWithResult(_0x3b647a,null))[_0x65f6('0x44')](handleError(_0x3b647a,null));};exports['destroy']=function(_0x47e749,_0x42d453){return db['CloudProvider'][_0x65f6('0x40')]({'where':{'id':_0x47e749[_0x65f6('0x3f')]['id']}})['then'](handleEntityNotFound(_0x42d453,null))[_0x65f6('0x21')](removeEntity(_0x42d453,null))['catch'](handleError(_0x42d453,null));};
\ No newline at end of file
+var _0x3d3a=['keys','filters','intersection','model','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','service','MicrosoftAzure','decryptString','data3','catch','show','params','rawAttributes','includeAll','create','body','Service\x20parameter\x20not\x20specified','values','includes','encryptString','destroy','find','findOne','error','get','state','Invalid\x20state\x20parameter','from','base64','toString','ascii','isValidIdToken','id_token','oauth2Claims','Unable\x20to\x20validate\x20id_token','del','getOauth2MicrosoftAccessToken','data5','access_token','data6','refresh_token','startRefreshInterval','emit','Invalid\x20authentication\x20state\x20parameter','message','Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s','lodash','ioredis','../../components/parsers/qs','../../config/environment','../../mysqldb','./cloudProvider.oauth','redis','defaults','localhost','socket.io-emitter','sendStatus','status','json','undefined','limit','count','offset','set','update','then','end','stack','name','send','index','map','CloudProvider','fieldName','type','key','query'];(function(_0x3bc3b4,_0x5acff4){var _0x4c546b=function(_0x158717){while(--_0x158717){_0x3bc3b4['push'](_0x3bc3b4['shift']());}};_0x4c546b(++_0x5acff4);}(_0x3d3a,0x1a3));var _0xa3d3=function(_0x503c5a,_0x269d5d){_0x503c5a=_0x503c5a-0x0;var _0x2b92b3=_0x3d3a[_0x503c5a];return _0x2b92b3;};'use strict';var _=require(_0xa3d3('0x0'));var Redis=require(_0xa3d3('0x1'));var qs=require(_0xa3d3('0x2'));var encryptor=require('../../components/encryptor');var config=require(_0xa3d3('0x3'));var logger=require('../../config/logger')('api');var db=require(_0xa3d3('0x4'))['db'];var oauth=require(_0xa3d3('0x5'));config[_0xa3d3('0x6')]=_[_0xa3d3('0x7')](config['redis'],{'host':_0xa3d3('0x8'),'port':0x18eb});var socket=require(_0xa3d3('0x9'))(new Redis(config[_0xa3d3('0x6')]));var redis=new Redis(config['redis']);function respondWithStatusCode(_0x113465,_0x15e168){_0x15e168=_0x15e168||0xcc;return function(_0x40615f){if(_0x40615f){return _0x113465[_0xa3d3('0xa')](_0x15e168);}return _0x113465[_0xa3d3('0xb')](_0x15e168)['end']();};}function respondWithResult(_0x17cba0,_0x54ed2b){_0x54ed2b=_0x54ed2b||0xc8;return function(_0x39f7f2){if(_0x39f7f2){return _0x17cba0[_0xa3d3('0xb')](_0x54ed2b)[_0xa3d3('0xc')](_0x39f7f2);}};}function respondWithFilteredResult(_0x4d55e5,_0x3dd3fc){return function(_0x3893da){if(_0x3893da){var _0x520e55=typeof _0x3dd3fc['offset']===_0xa3d3('0xd')&&typeof _0x3dd3fc[_0xa3d3('0xe')]===_0xa3d3('0xd');var _0x1b1f08=_0x3893da[_0xa3d3('0xf')];var _0x5d4335=_0x520e55?0x0:_0x3dd3fc[_0xa3d3('0x10')];var _0xd4c759=_0x520e55?_0x3893da['count']:_0x3dd3fc[_0xa3d3('0x10')]+_0x3dd3fc[_0xa3d3('0xe')];var _0x5d25dc;if(_0xd4c759>=_0x1b1f08){_0xd4c759=_0x1b1f08;_0x5d25dc=0xc8;}else{_0x5d25dc=0xce;}_0x4d55e5[_0xa3d3('0xb')](_0x5d25dc);return _0x4d55e5[_0xa3d3('0x11')]('Content-Range',_0x5d4335+'-'+_0xd4c759+'/'+_0x1b1f08)['json'](_0x3893da);}return null;};}function saveUpdates(_0x225e08){return function(_0x25d372){if(_0x25d372){return _0x25d372[_0xa3d3('0x12')](_0x225e08)[_0xa3d3('0x13')](function(_0x1a757c){return _0x1a757c;});}return null;};}function removeEntity(_0x44dc90){return function(_0x367fb8){if(_0x367fb8){return _0x367fb8['destroy']()['then'](function(){_0x44dc90['status'](0xcc)[_0xa3d3('0x14')]();});}};}function handleEntityNotFound(_0x393e1f){return function(_0xd4ced2){if(!_0xd4ced2){_0x393e1f[_0xa3d3('0xa')](0x194);}return _0xd4ced2;};}function handleError(_0x115e99,_0x4834b5){_0x4834b5=_0x4834b5||0x1f4;return function(_0x399716){logger['error'](_0x399716[_0xa3d3('0x15')]);if(_0x399716['name']){delete _0x399716[_0xa3d3('0x16')];}_0x115e99['status'](_0x4834b5)[_0xa3d3('0x17')](_0x399716);};}function maskClientSecret(_0x2c6433){return _['padEnd'](_0x2c6433['slice'](0x0,0x3),0x14,'*');}exports[_0xa3d3('0x18')]=function(_0xf8f357,_0x3f76cb){var _0x187c37={},_0x3ed52d={},_0x5834e5={'count':0x0,'rows':[]};var _0xb8e84c=_[_0xa3d3('0x19')](db[_0xa3d3('0x1a')]['rawAttributes'],function(_0x23c2d1){return{'name':_0x23c2d1[_0xa3d3('0x1b')],'type':_0x23c2d1[_0xa3d3('0x1c')][_0xa3d3('0x1d')]};});_0x3ed52d['model']=_[_0xa3d3('0x19')](_0xb8e84c,_0xa3d3('0x16'));_0x3ed52d[_0xa3d3('0x1e')]=_[_0xa3d3('0x1f')](_0xf8f357[_0xa3d3('0x1e')]);_0x3ed52d[_0xa3d3('0x20')]=_[_0xa3d3('0x21')](_0x3ed52d[_0xa3d3('0x22')],_0x3ed52d[_0xa3d3('0x1e')]);_0x187c37[_0xa3d3('0x23')]=_[_0xa3d3('0x21')](_0x3ed52d['model'],qs[_0xa3d3('0x24')](_0xf8f357['query']['fields']));_0x187c37[_0xa3d3('0x23')]=_0x187c37[_0xa3d3('0x23')][_0xa3d3('0x25')]?_0x187c37[_0xa3d3('0x23')]:_0x3ed52d['model'];if(!_0xf8f357[_0xa3d3('0x1e')]['hasOwnProperty'](_0xa3d3('0x26'))){_0x187c37['limit']=qs[_0xa3d3('0xe')](_0xf8f357[_0xa3d3('0x1e')][_0xa3d3('0xe')]);_0x187c37[_0xa3d3('0x10')]=qs[_0xa3d3('0x10')](_0xf8f357['query'][_0xa3d3('0x10')]);}_0x187c37[_0xa3d3('0x27')]=qs[_0xa3d3('0x28')](_0xf8f357[_0xa3d3('0x1e')][_0xa3d3('0x28')]);_0x187c37[_0xa3d3('0x29')]=qs['filters'](_[_0xa3d3('0x2a')](_0xf8f357['query'],_0x3ed52d['filters']),_0xb8e84c);if(_0xf8f357['query'][_0xa3d3('0x2b')]){_0x187c37[_0xa3d3('0x29')]=_[_0xa3d3('0x2c')](_0x187c37[_0xa3d3('0x29')],{'$or':_[_0xa3d3('0x19')](_0xb8e84c,function(_0xa4b43){if(_0xa4b43[_0xa3d3('0x1c')]!==_0xa3d3('0x2d')){var _0xb2ac29={};_0xb2ac29[_0xa4b43[_0xa3d3('0x16')]]={'$like':'%'+_0xf8f357[_0xa3d3('0x1e')][_0xa3d3('0x2b')]+'%'};return _0xb2ac29;}})});}_0x187c37=_['merge']({},_0x187c37,_0xf8f357[_0xa3d3('0x2e')]);var _0x2903cc={'where':_0x187c37['where']};return db['CloudProvider'][_0xa3d3('0xf')](_0x2903cc)[_0xa3d3('0x13')](function(_0x21b3df){_0x5834e5[_0xa3d3('0xf')]=_0x21b3df;if(_0xf8f357[_0xa3d3('0x1e')]['includeAll']){_0x187c37[_0xa3d3('0x2f')]=[{'all':!![]}];}return db[_0xa3d3('0x1a')][_0xa3d3('0x30')](_0x187c37);})[_0xa3d3('0x13')](function(_0x20ad4b){_0x5834e5['rows']=_[_0xa3d3('0x19')](_0x20ad4b,function(_0x4417b4){if(_0x4417b4[_0xa3d3('0x31')]===_0xa3d3('0x32')){var _0x3f9f2d=encryptor[_0xa3d3('0x33')](_0x4417b4[_0xa3d3('0x34')]);_0x4417b4[_0xa3d3('0x34')]=maskClientSecret(_0x3f9f2d);}return _0x4417b4;});return _0x5834e5;})['then'](respondWithFilteredResult(_0x3f76cb,_0x187c37))[_0xa3d3('0x35')](handleError(_0x3f76cb,null));};exports[_0xa3d3('0x36')]=function(_0x1138bc,_0x2c54c7){var _0x47d682={'raw':!![],'where':{'id':_0x1138bc[_0xa3d3('0x37')]['id']}},_0x4da036={};_0x4da036['model']=_[_0xa3d3('0x1f')](db[_0xa3d3('0x1a')][_0xa3d3('0x38')]);_0x4da036['query']=_[_0xa3d3('0x1f')](_0x1138bc[_0xa3d3('0x1e')]);_0x4da036[_0xa3d3('0x20')]=_[_0xa3d3('0x21')](_0x4da036[_0xa3d3('0x22')],_0x4da036[_0xa3d3('0x1e')]);_0x47d682['attributes']=_[_0xa3d3('0x21')](_0x4da036['model'],qs[_0xa3d3('0x24')](_0x1138bc[_0xa3d3('0x1e')][_0xa3d3('0x24')]));_0x47d682[_0xa3d3('0x23')]=_0x47d682[_0xa3d3('0x23')]['length']?_0x47d682['attributes']:_0x4da036[_0xa3d3('0x22')];if(_0x1138bc[_0xa3d3('0x1e')][_0xa3d3('0x39')]){_0x47d682[_0xa3d3('0x2f')]=[{'all':!![]}];}_0x47d682=_[_0xa3d3('0x2c')]({},_0x47d682,_0x1138bc[_0xa3d3('0x2e')]);return db[_0xa3d3('0x1a')]['find'](_0x47d682)[_0xa3d3('0x13')](handleEntityNotFound(_0x2c54c7,null))[_0xa3d3('0x13')](function(_0x555a09){if(_0x555a09[_0xa3d3('0x31')]===_0xa3d3('0x32')){var _0x44a35e=encryptor[_0xa3d3('0x33')](_0x555a09[_0xa3d3('0x34')]);_0x555a09[_0xa3d3('0x34')]=maskClientSecret(_0x44a35e);}return _0x555a09;})[_0xa3d3('0x13')](respondWithResult(_0x2c54c7,null))['catch'](handleError(_0x2c54c7,null));};exports[_0xa3d3('0x3a')]=function(_0x4a3fb3,_0x160fe3){if(!_0x4a3fb3[_0xa3d3('0x3b')][_0xa3d3('0x16')])throw new Error('Name\x20parameter\x20not\x20specified');if(!_0x4a3fb3[_0xa3d3('0x3b')]['service'])throw new Error(_0xa3d3('0x3c'));var _0x1658ec=db[_0xa3d3('0x1a')][_0xa3d3('0x38')]['service'][_0xa3d3('0x3d')];if(!_0x1658ec[_0xa3d3('0x3e')](_0x4a3fb3[_0xa3d3('0x3b')][_0xa3d3('0x31')]))throw new Error('Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20'+_0x1658ec['join'](',\x20'));if(_0x4a3fb3['body'][_0xa3d3('0x31')]==='MicrosoftAzure'&&_0x4a3fb3['body']['data3']){_0x4a3fb3[_0xa3d3('0x3b')]['data3']=encryptor['encryptString'](_0x4a3fb3[_0xa3d3('0x3b')]['data3']);}return db['CloudProvider'][_0xa3d3('0x3a')](_0x4a3fb3[_0xa3d3('0x3b')],{})[_0xa3d3('0x13')](respondWithResult(_0x160fe3,0xc9))['catch'](handleError(_0x160fe3,null));};exports['update']=function(_0x4f874c,_0x451f08){if(_0x4f874c['body']['id']){delete _0x4f874c[_0xa3d3('0x3b')]['id'];}return db[_0xa3d3('0x1a')]['find']({'where':{'id':_0x4f874c[_0xa3d3('0x37')]['id']}})['then'](handleEntityNotFound(_0x451f08,null))[_0xa3d3('0x13')](function(_0x38c697){if(_0x38c697[_0xa3d3('0x31')]==='MicrosoftAzure'&&_0x4f874c['body'][_0xa3d3('0x34')]){_0x4f874c[_0xa3d3('0x3b')][_0xa3d3('0x34')]=encryptor[_0xa3d3('0x3f')](_0x4f874c['body'][_0xa3d3('0x34')]);}return _0x38c697;})[_0xa3d3('0x13')](saveUpdates(_0x4f874c[_0xa3d3('0x3b')],null))[_0xa3d3('0x13')](respondWithResult(_0x451f08,null))[_0xa3d3('0x35')](handleError(_0x451f08,null));};exports[_0xa3d3('0x40')]=function(_0x1d70d7,_0x434b7e){return db[_0xa3d3('0x1a')][_0xa3d3('0x41')]({'where':{'id':_0x1d70d7[_0xa3d3('0x37')]['id']}})[_0xa3d3('0x13')](handleEntityNotFound(_0x434b7e,null))[_0xa3d3('0x13')](removeEntity(_0x434b7e,null))[_0xa3d3('0x35')](handleError(_0x434b7e,null));};exports['oauth2MicrosoftAuthorize']=function(_0x4de710,_0x1a286b){return db[_0xa3d3('0x1a')][_0xa3d3('0x42')]({'where':{'id':_0x4de710[_0xa3d3('0x37')]['id']},'raw':!![]})['then'](function(_0x977597){if(!_0x977597)return _0x1a286b[_0xa3d3('0xa')](0x194);return{'url':oauth['generateMicrosoftAuthorizationUrl'](_0x977597,_0x4de710['user']['id'])};})['then'](respondWithResult(_0x1a286b,null))['catch'](handleError(_0x1a286b,null));};exports['oauth2MicrosoftCallback']=function(_0x37025f,_0x136fb5){var _0x56177f=_0x37025f[_0xa3d3('0x3b')];var _0x243928;var _0x37be6f;if(_0x56177f[_0xa3d3('0x43')])throw _0x56177f;redis[_0xa3d3('0x44')](_0x56177f[_0xa3d3('0x45')])['then'](function(_0x59d008){if(!_0x59d008)throw new Error(_0xa3d3('0x46'));_0x243928=JSON['parse'](_0x59d008);var _0x56d57a=Buffer[_0xa3d3('0x47')](_0x56177f['state'],_0xa3d3('0x48'))[_0xa3d3('0x49')](_0xa3d3('0x4a'));_0x37be6f=JSON['parse'](_0x56d57a);if(!oauth[_0xa3d3('0x4b')](_0x56177f[_0xa3d3('0x4c')],_0x243928[_0xa3d3('0x4d')]))throw new Error(_0xa3d3('0x4e'));redis[_0xa3d3('0x4f')](_0x56177f[_0xa3d3('0x45')]);return oauth[_0xa3d3('0x50')](_0x56177f['code'],_0x243928);})[_0xa3d3('0x13')](function(_0x11cad2){_0x243928[_0xa3d3('0x51')]=_0x11cad2[_0xa3d3('0x52')];_0x243928[_0xa3d3('0x53')]=_0x11cad2[_0xa3d3('0x54')];return db[_0xa3d3('0x1a')][_0xa3d3('0x12')]({'data5':_0x243928[_0xa3d3('0x51')],'data6':_0x243928['data6']},{'where':{'id':_0x243928['id']}});})[_0xa3d3('0x13')](function(){oauth[_0xa3d3('0x55')](_0x243928);socket['emit']('microsoftAuthorization:success',{'id':_0x37be6f['id']});return;})['then'](respondWithStatusCode(_0x136fb5,null))[_0xa3d3('0x35')](function(_0x1fead8){if(_0x37be6f){socket[_0xa3d3('0x56')]('microsoftAuthorization:error',{'id':_0x37be6f['id']});}if(!_0x243928){logger[_0xa3d3('0x43')](_0xa3d3('0x57'),_0x1fead8);return _0x136fb5['status'](0x1f4)[_0xa3d3('0x17')](_0x1fead8[_0xa3d3('0x58')]);}logger[_0xa3d3('0x43')](_0xa3d3('0x59'),_0x243928['id'],JSON['stringify'](_0x1fead8));});};
\ No newline at end of file