Built motion from commit 4c579f6b.|2.5.32
[motion2.git] / server / api / user / user.model.js
index abf65bc..c2eae18 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbc2f=['VoiceChanSpy','findAll','concat','catch','exports','models','define','User','users','utf8','userProfileId','undefined','resolve','UserProfile','find','privacyEnabled','updatePassword','then','changed','updateMd5Password','internal','VoiceExtension','bulkCreate','destroy','encryptPassword','function','Missing\x20Callback','randomBytes','toString','base64','salt','pbkdf2Sync','sha1','pbkdf2','provider','Invalid\x20password','makeSalt',':asterisk:','md5secret','crypto','util','lodash','./user.attributes','google','length','context','from-sip','system','format','%s%s','prefix','push','merge','Set','CDR(type)=%s','chanspy','${UNIQUEID}.%s,a','recordingFormat','auth','Authenticate','password','SIP/%s,%s','name','options','join','record','StopMixMonitor','wav','WAV','gsm','CDR(type)=internal','extensionMonitor','includes','_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','Dial','Hangup'];(function(_0x5329ac,_0xfc0fec){var _0x4e1ed2=function(_0x30e580){while(--_0x30e580){_0x5329ac['push'](_0x5329ac['shift']());}};_0x4e1ed2(++_0xfc0fec);}(_0xbc2f,0x157));var _0xfbc2=function(_0x11c9cf,_0x2cb52f){_0x11c9cf=_0x11c9cf-0x0;var _0x19f248=_0xbc2f[_0x11c9cf];return _0x19f248;};'use strict';var BPromise=require('bluebird');var crypto=require(_0xfbc2('0x0'));var util=require(_0xfbc2('0x1'));var md5=require('md5');var _=require(_0xfbc2('0x2'));var attributes=require(_0xfbc2('0x3'));var authTypes=[_0xfbc2('0x4')];var validatePresenceOf=function(_0x50fe11){return _0x50fe11&&_0x50fe11[_0xfbc2('0x5')];};var getChanSpyApplications=function(_0x2efb1e,_0x222691,_0x46c466){var _0x2821f9={'context':_0x2efb1e[_0xfbc2('0x6')]||_0xfbc2('0x7'),'type':_0xfbc2('0x8'),'isApp':![],'UserId':_0x2efb1e['id']};var _0x19634b=[];for(var _0x130e1c=0x0,_0x10f07a=0x1;_0x130e1c<_0x46c466[_0xfbc2('0x5')];_0x130e1c++,_0x10f07a=0x1){var _0x3bae1a={'exten':util[_0xfbc2('0x9')](_0xfbc2('0xa'),_0x46c466[_0x130e1c][_0xfbc2('0xb')],_0x222691),'ChanSpyId':_0x46c466[_0x130e1c]['id']};_0x19634b[_0xfbc2('0xc')](_[_0xfbc2('0xd')]({'app':_0xfbc2('0xe'),'appdata':util['format'](_0xfbc2('0xf'),_0xfbc2('0x10')),'priority':_0x10f07a++},_0x2821f9,_0x3bae1a));if(_0x46c466[_0x130e1c]['record']){_0x19634b[_0xfbc2('0xc')](_[_0xfbc2('0xd')]({'app':'MixMonitor','appdata':util[_0xfbc2('0x9')](_0xfbc2('0x11'),_0x46c466[_0x130e1c][_0xfbc2('0x12')]),'priority':_0x10f07a++},_0x2821f9,_0x3bae1a));}if(_0x46c466[_0x130e1c][_0xfbc2('0x13')]){_0x19634b[_0xfbc2('0xc')](_['merge']({'app':_0xfbc2('0x14'),'appdata':_0x46c466[_0x130e1c][_0xfbc2('0x15')],'priority':_0x10f07a++},_0x2821f9,_0x3bae1a));}_0x19634b[_0xfbc2('0xc')](_[_0xfbc2('0xd')]({'app':'ChanSpy','appdata':util['format'](_0xfbc2('0x16'),_0x2efb1e[_0xfbc2('0x17')],_0x46c466[_0x130e1c][_0xfbc2('0x18')]?_0x46c466[_0x130e1c][_0xfbc2('0x18')][_0xfbc2('0x19')](''):''),'priority':_0x10f07a++},_0x2821f9,_0x3bae1a));if(_0x46c466[_0x130e1c][_0xfbc2('0x1a')]){_0x19634b[_0xfbc2('0xc')](_[_0xfbc2('0xd')]({'app':_0xfbc2('0x1b'),'priority':_0x10f07a++},_0x2821f9,_0x3bae1a));}}return _0x19634b;};var getUserApplications=function(_0x596672,_0x523b39){var _0x59fe17=[_0xfbc2('0x1c'),_0xfbc2('0x1d'),_0xfbc2('0x1e')];var _0x49aed2={'context':_0x596672['context']||_0xfbc2('0x7'),'exten':_0x523b39,'type':_0xfbc2('0x8'),'isApp':![],'UserId':_0x596672['id']};var _0x14a3b0=[{'app':_0xfbc2('0xe'),'appdata':_0xfbc2('0x1f')}];if(_0x596672[_0xfbc2('0x20')]&&_[_0xfbc2('0x21')](_0x59fe17,_0x596672[_0xfbc2('0x20')])){_0x14a3b0[_0xfbc2('0xc')]({'app':_0xfbc2('0xe'),'appdata':_0xfbc2('0x22')});_0x14a3b0['push']({'app':'Set','appdata':util[_0xfbc2('0x9')]('_XCALLY_MIXMONITOR_FORMAT=%s',_0x596672['extensionMonitor'])});_0x14a3b0[_0xfbc2('0xc')]({'app':'Dial','appdata':util[_0xfbc2('0x9')]('SIP/%s,,tTxXU(xcally-mixmonitor-context)',_0x596672[_0xfbc2('0x17')])});}else{_0x14a3b0[_0xfbc2('0xc')]({'app':_0xfbc2('0x23'),'appdata':util[_0xfbc2('0x9')]('SIP/%s,,tTxX',_0x596672[_0xfbc2('0x17')])});}_0x14a3b0[_0xfbc2('0xc')]({'app':_0xfbc2('0x24')});for(var _0x415df3=0x0;_0x415df3<_0x14a3b0[_0xfbc2('0x5')];_0x415df3++){_0x14a3b0[_0x415df3]['priority']=_0x415df3+0x1;_0x14a3b0[_0x415df3]=_['defaults'](_0x14a3b0[_0x415df3],_0x49aed2);}return _0x14a3b0;};var getChanSpyPromise=function(_0x2dd4e4,_0x4a0b41){return new BPromise(function(_0x32362d,_0x237738){return _0x2dd4e4[_0xfbc2('0x25')][_0xfbc2('0x26')]()['then'](function(_0x217027){if(_0x217027){var _0x3d0731=getChanSpyApplications(_0x4a0b41,_0x4a0b41['internal'],_0x217027);if(_0x4a0b41['internal']!=_0x4a0b41['name']){_0x3d0731=_0x3d0731[_0xfbc2('0x27')](getChanSpyApplications(_0x4a0b41,_0x4a0b41['name'],_0x217027));}return _0x32362d(_0x3d0731);}return _0x32362d([]);})[_0xfbc2('0x28')](function(_0xfe7d7a){_0x237738(_0xfe7d7a);});});};module[_0xfbc2('0x29')]=function(_0x1e3686,_0x5b2ab2){var _0x5a9d8d=_0x1e3686[_0xfbc2('0x2a')];return _0x1e3686[_0xfbc2('0x2b')](_0xfbc2('0x2c'),attributes,{'tableName':_0xfbc2('0x2d'),'charset':_0xfbc2('0x2e'),'collate':'utf8_bin','hooks':{'beforeCreate':function(_0x28339a,_0x3c141a,_0x189b12){var _0x19f6fe=typeof _0x28339a[_0xfbc2('0x2f')]===_0xfbc2('0x30')?BPromise[_0xfbc2('0x31')](null):_0x5a9d8d[_0xfbc2('0x32')][_0xfbc2('0x33')]({'where':{'id':_0x28339a[_0xfbc2('0x2f')]}});_0x19f6fe['then'](function(_0x599efb){if(_0x599efb){_0x28339a[_0xfbc2('0x34')]=_0x599efb['privacyEnabled'];}})['then'](function(){_0x28339a['updateMd5Password']();_0x28339a[_0xfbc2('0x35')](_0x189b12);})[_0xfbc2('0x28')](function(_0x2157f3){_0x189b12(_0x2157f3);});},'beforeUpdate':function(_0x25c741,_0x1c9401,_0x41f435){Promise[_0xfbc2('0x31')]()[_0xfbc2('0x36')](function(){if(_0x25c741[_0xfbc2('0x37')](_0xfbc2('0x2f'))===![])return;return _0x5a9d8d[_0xfbc2('0x32')][_0xfbc2('0x33')]({'where':{'id':_0x25c741['userProfileId']}})[_0xfbc2('0x36')](function(_0x4b1557){if(_0x4b1557)_0x25c741[_0xfbc2('0x34')]=_0x4b1557[_0xfbc2('0x34')];return;});})[_0xfbc2('0x36')](function(){if(_0x25c741['changed'](_0xfbc2('0x15'))){_0x25c741[_0xfbc2('0x38')]();return _0x25c741['updatePassword'](_0x41f435);}_0x41f435();})[_0xfbc2('0x28')](function(_0x14be92){_0x41f435(_0x14be92);});},'afterCreate':function(_0x23f0f4,_0x245d1f,_0x50e703){var _0x4a9b6f=getUserApplications(_0x23f0f4,_0x23f0f4[_0xfbc2('0x39')]);if(_0x23f0f4['internal']!=_0x23f0f4[_0xfbc2('0x17')]){_0x4a9b6f=_0x4a9b6f[_0xfbc2('0x27')](getUserApplications(_0x23f0f4,_0x23f0f4['name']));}return _0x5a9d8d[_0xfbc2('0x3a')][_0xfbc2('0x3b')](_0x4a9b6f)[_0xfbc2('0x36')](function(){if(_0x23f0f4[_0xfbc2('0x10')]){return getChanSpyPromise(_0x5a9d8d,_0x23f0f4);}})[_0xfbc2('0x36')](function(_0x550f4f){if(_0x550f4f&&_0x550f4f[_0xfbc2('0x5')]){return _0x5a9d8d[_0xfbc2('0x3a')][_0xfbc2('0x3b')](_0x550f4f);}})['then'](function(){_0x50e703();})[_0xfbc2('0x28')](function(_0x3390f5){_0x50e703(_0x3390f5);});},'afterUpdate':function(_0xfdb063,_0x1451f5,_0x3ef634){return BPromise[_0xfbc2('0x31')]()[_0xfbc2('0x36')](function(){if(_0xfdb063[_0xfbc2('0x37')](_0xfbc2('0x10'))||_0xfdb063['changed'](_0xfbc2('0x6'))){return _0x5a9d8d['VoiceExtension'][_0xfbc2('0x3c')]({'where':{'UserId':_0xfdb063['id'],'type':_0xfbc2('0x8'),'ChanSpyId':{'$ne':null}}})['then'](function(){if(_0xfdb063[_0xfbc2('0x10')]){return getChanSpyPromise(_0x5a9d8d,_0xfdb063)[_0xfbc2('0x36')](function(_0x20395d){if(_0x20395d&&_0x20395d[_0xfbc2('0x5')]){return _0x5a9d8d[_0xfbc2('0x3a')]['bulkCreate'](_0x20395d);}});}});}})[_0xfbc2('0x36')](function(){if(_0xfdb063['changed'](_0xfbc2('0x20'))||_0xfdb063[_0xfbc2('0x37')](_0xfbc2('0x6'))){return _0x5a9d8d[_0xfbc2('0x3a')]['destroy']({'where':{'UserId':_0xfdb063['id'],'type':_0xfbc2('0x8'),'ChanSpyId':null}})['then'](function(){var _0xd06b26=getUserApplications(_0xfdb063,_0xfdb063[_0xfbc2('0x39')]);if(_0xfdb063[_0xfbc2('0x39')]!=_0xfdb063[_0xfbc2('0x17')]){_0xd06b26=_0xd06b26[_0xfbc2('0x27')](getUserApplications(_0xfdb063,_0xfdb063[_0xfbc2('0x17')]));}return _0x5a9d8d[_0xfbc2('0x3a')]['bulkCreate'](_0xd06b26);});}})[_0xfbc2('0x36')](function(){_0x3ef634();})[_0xfbc2('0x28')](function(_0x5f5760){_0x3ef634(_0x5f5760);});},'afterDestroy':function(_0x500420,_0x1605fb){return _0x5a9d8d[_0xfbc2('0x3a')]['destroy']({'where':{'UserId':_0x500420['id'],'type':_0xfbc2('0x8')}});}},'instanceMethods':{'authenticate':function(_0x41b6d4,_0x4c91d5){if(!_0x4c91d5){return this[_0xfbc2('0x15')]===this[_0xfbc2('0x3d')](_0x41b6d4);}var _0x353587=this;this[_0xfbc2('0x3d')](_0x41b6d4,function(_0x4ad7fc,_0x590978){if(_0x4ad7fc){_0x4c91d5(_0x4ad7fc);}if(_0x353587[_0xfbc2('0x15')]===_0x590978){_0x4c91d5(null,!![]);}else{_0x4c91d5(null,![]);}});},'makeSalt':function(_0x1971f2,_0x3a796a){var _0x4bdb10=0x10;if(typeof arguments[0x0]===_0xfbc2('0x3e')){_0x3a796a=arguments[0x0];_0x1971f2=_0x4bdb10;}else if(typeof arguments[0x1]===_0xfbc2('0x3e')){_0x3a796a=arguments[0x1];}else{throw new Error(_0xfbc2('0x3f'));}if(!_0x1971f2){_0x1971f2=_0x4bdb10;}return crypto[_0xfbc2('0x40')](_0x1971f2,function(_0x3cb840,_0x4ddfb2){if(_0x3cb840){_0x3a796a(_0x3cb840);}return _0x3a796a(null,_0x4ddfb2[_0xfbc2('0x41')](_0xfbc2('0x42')));});},'encryptPassword':function(_0x143a75,_0x35a8b){if(!_0x143a75||!this['salt']){return _0x35a8b?_0x35a8b(null):null;}var _0x2d9af9=0x2710;var _0x437580=0x40;var _0x4eb02c=new Buffer(this[_0xfbc2('0x43')],_0xfbc2('0x42'));if(!_0x35a8b){return crypto[_0xfbc2('0x44')](_0x143a75,_0x4eb02c,_0x2d9af9,_0x437580,_0xfbc2('0x45'))[_0xfbc2('0x41')](_0xfbc2('0x42'));}return crypto[_0xfbc2('0x46')](_0x143a75,_0x4eb02c,_0x2d9af9,_0x437580,'sha1',function(_0x344680,_0x27f3c4){if(_0x344680){_0x35a8b(_0x344680);}return _0x35a8b(null,_0x27f3c4[_0xfbc2('0x41')]('base64'));});},'updatePassword':function(_0x3aeefc){if(!this[_0xfbc2('0x15')]){return _0x3aeefc(null);}if(!validatePresenceOf(this[_0xfbc2('0x15')])&&authTypes['indexOf'](this[_0xfbc2('0x47')])===-0x1){_0x3aeefc(new Error(_0xfbc2('0x48')));}var _0x3a7d04=this;this[_0xfbc2('0x49')](function(_0x27ac3b,_0x3fe603){if(_0x27ac3b){return _0x3aeefc(_0x27ac3b);}_0x3a7d04[_0xfbc2('0x43')]=_0x3fe603;_0x3a7d04[_0xfbc2('0x3d')](_0x3a7d04[_0xfbc2('0x15')],function(_0x3dd58c,_0x243351){if(_0x3dd58c){_0x3aeefc(_0x3dd58c);}_0x3a7d04[_0xfbc2('0x15')]=_0x243351;_0x3aeefc(null);});});},'updateMd5Password':function(){this['md5secret']=md5(this[_0xfbc2('0x17')]+_0xfbc2('0x4a')+this[_0xfbc2('0x15')]);return this[_0xfbc2('0x4b')];}}});};
\ No newline at end of file
+var _0x38e4=['CDR(type)=internal','extensionMonitor','_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','_XCALLY_MIXMONITOR_FORMAT=%s','Dial','SIP/%s,,tTxXU(xcally-mixmonitor-context)','Hangup','VoiceChanSpy','findAll','then','internal','concat','catch','exports','define','users','utf8','userProfileId','UserProfile','find','privacyEnabled','updateMd5Password','updatePassword','changed','bulkCreate','VoiceExtension','resolve','destroy','encryptPassword','function','Missing\x20Callback','randomBytes','toString','base64','salt','sha1','pbkdf2','provider','Invalid\x20password','makeSalt','md5secret',':asterisk:','bluebird','crypto','md5','lodash','google','length','context','from-sip','system','format','%s%s','prefix','push','merge','Set','CDR(type)=%s','chanspy','record','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','Authenticate','password','ChanSpy','SIP/%s,%s','name','options','join','StopMixMonitor','gsm'];(function(_0x256b72,_0x340985){var _0x2183e3=function(_0xf7fd37){while(--_0xf7fd37){_0x256b72['push'](_0x256b72['shift']());}};_0x2183e3(++_0x340985);}(_0x38e4,0xba));var _0x438e=function(_0x397e5f,_0x454c8f){_0x397e5f=_0x397e5f-0x0;var _0x5302b8=_0x38e4[_0x397e5f];return _0x5302b8;};'use strict';var BPromise=require(_0x438e('0x0'));var crypto=require(_0x438e('0x1'));var util=require('util');var md5=require(_0x438e('0x2'));var _=require(_0x438e('0x3'));var attributes=require('./user.attributes');var authTypes=[_0x438e('0x4')];var validatePresenceOf=function(_0x57fca2){return _0x57fca2&&_0x57fca2[_0x438e('0x5')];};var getChanSpyApplications=function(_0x2eb4d0,_0x10ad0f,_0xeb60b3){var _0x3f2d23={'context':_0x2eb4d0[_0x438e('0x6')]||_0x438e('0x7'),'type':_0x438e('0x8'),'isApp':![],'UserId':_0x2eb4d0['id']};var _0x3865bc=[];for(var _0x135f2c=0x0,_0x95949e=0x1;_0x135f2c<_0xeb60b3['length'];_0x135f2c++,_0x95949e=0x1){var _0x31d608={'exten':util[_0x438e('0x9')](_0x438e('0xa'),_0xeb60b3[_0x135f2c][_0x438e('0xb')],_0x10ad0f),'ChanSpyId':_0xeb60b3[_0x135f2c]['id']};_0x3865bc[_0x438e('0xc')](_[_0x438e('0xd')]({'app':_0x438e('0xe'),'appdata':util[_0x438e('0x9')](_0x438e('0xf'),_0x438e('0x10')),'priority':_0x95949e++},_0x3f2d23,_0x31d608));if(_0xeb60b3[_0x135f2c][_0x438e('0x11')]){_0x3865bc[_0x438e('0xc')](_[_0x438e('0xd')]({'app':_0x438e('0x12'),'appdata':util[_0x438e('0x9')](_0x438e('0x13'),_0xeb60b3[_0x135f2c][_0x438e('0x14')]),'priority':_0x95949e++},_0x3f2d23,_0x31d608));}if(_0xeb60b3[_0x135f2c]['auth']){_0x3865bc[_0x438e('0xc')](_[_0x438e('0xd')]({'app':_0x438e('0x15'),'appdata':_0xeb60b3[_0x135f2c][_0x438e('0x16')],'priority':_0x95949e++},_0x3f2d23,_0x31d608));}_0x3865bc['push'](_[_0x438e('0xd')]({'app':_0x438e('0x17'),'appdata':util[_0x438e('0x9')](_0x438e('0x18'),_0x2eb4d0[_0x438e('0x19')],_0xeb60b3[_0x135f2c][_0x438e('0x1a')]?_0xeb60b3[_0x135f2c]['options'][_0x438e('0x1b')](''):''),'priority':_0x95949e++},_0x3f2d23,_0x31d608));if(_0xeb60b3[_0x135f2c][_0x438e('0x11')]){_0x3865bc[_0x438e('0xc')](_[_0x438e('0xd')]({'app':_0x438e('0x1c'),'priority':_0x95949e++},_0x3f2d23,_0x31d608));}}return _0x3865bc;};var getUserApplications=function(_0x171a26,_0x518352){var _0x94a9cd=['wav','WAV',_0x438e('0x1d')];var _0x383db5={'context':_0x171a26['context']||_0x438e('0x7'),'exten':_0x518352,'type':_0x438e('0x8'),'isApp':![],'UserId':_0x171a26['id']};var _0xca6ffe=[{'app':_0x438e('0xe'),'appdata':_0x438e('0x1e')}];if(_0x171a26[_0x438e('0x1f')]&&_['includes'](_0x94a9cd,_0x171a26['extensionMonitor'])){_0xca6ffe[_0x438e('0xc')]({'app':_0x438e('0xe'),'appdata':_0x438e('0x20')});_0xca6ffe[_0x438e('0xc')]({'app':_0x438e('0xe'),'appdata':util['format'](_0x438e('0x21'),_0x171a26[_0x438e('0x1f')])});_0xca6ffe[_0x438e('0xc')]({'app':_0x438e('0x22'),'appdata':util[_0x438e('0x9')](_0x438e('0x23'),_0x171a26[_0x438e('0x19')])});}else{_0xca6ffe['push']({'app':_0x438e('0x22'),'appdata':util[_0x438e('0x9')]('SIP/%s,,tTxX',_0x171a26['name'])});}_0xca6ffe[_0x438e('0xc')]({'app':_0x438e('0x24')});for(var _0x335538=0x0;_0x335538<_0xca6ffe[_0x438e('0x5')];_0x335538++){_0xca6ffe[_0x335538]['priority']=_0x335538+0x1;_0xca6ffe[_0x335538]=_['defaults'](_0xca6ffe[_0x335538],_0x383db5);}return _0xca6ffe;};var getChanSpyPromise=function(_0x292cb2,_0x494b0a){return new BPromise(function(_0xeae9d0,_0x40e9f9){return _0x292cb2[_0x438e('0x25')][_0x438e('0x26')]()[_0x438e('0x27')](function(_0x4a1d85){if(_0x4a1d85){var _0x2d41e2=getChanSpyApplications(_0x494b0a,_0x494b0a[_0x438e('0x28')],_0x4a1d85);if(_0x494b0a['internal']!=_0x494b0a[_0x438e('0x19')]){_0x2d41e2=_0x2d41e2[_0x438e('0x29')](getChanSpyApplications(_0x494b0a,_0x494b0a[_0x438e('0x19')],_0x4a1d85));}return _0xeae9d0(_0x2d41e2);}return _0xeae9d0([]);})[_0x438e('0x2a')](function(_0x5e42bc){_0x40e9f9(_0x5e42bc);});});};module[_0x438e('0x2b')]=function(_0x749c77,_0x224962){var _0xf329aa=_0x749c77['models'];return _0x749c77[_0x438e('0x2c')]('User',attributes,{'tableName':_0x438e('0x2d'),'charset':_0x438e('0x2e'),'collate':'utf8_bin','hooks':{'beforeCreate':function(_0x4bb567,_0x16d19e,_0x594155){var _0x3bbf4e=typeof _0x4bb567[_0x438e('0x2f')]==='undefined'?BPromise['resolve'](null):_0xf329aa[_0x438e('0x30')][_0x438e('0x31')]({'where':{'id':_0x4bb567[_0x438e('0x2f')]}});_0x3bbf4e[_0x438e('0x27')](function(_0x11d68b){if(_0x11d68b){_0x4bb567[_0x438e('0x32')]=_0x11d68b[_0x438e('0x32')];}})[_0x438e('0x27')](function(){_0x4bb567[_0x438e('0x33')]();_0x4bb567[_0x438e('0x34')](_0x594155);})[_0x438e('0x2a')](function(_0x43b3ee){_0x594155(_0x43b3ee);});},'beforeUpdate':function(_0x1a24ea,_0x27bd67,_0x1f5cff){Promise['resolve']()['then'](function(){if(_0x1a24ea[_0x438e('0x35')](_0x438e('0x2f'))===![])return;return _0xf329aa[_0x438e('0x30')][_0x438e('0x31')]({'where':{'id':_0x1a24ea[_0x438e('0x2f')]}})[_0x438e('0x27')](function(_0x400d68){if(_0x400d68)_0x1a24ea[_0x438e('0x32')]=_0x400d68[_0x438e('0x32')];return;});})[_0x438e('0x27')](function(){if(_0x1a24ea[_0x438e('0x35')](_0x438e('0x16'))){_0x1a24ea[_0x438e('0x33')]();return _0x1a24ea[_0x438e('0x34')](_0x1f5cff);}_0x1f5cff();})[_0x438e('0x2a')](function(_0x12ce6f){_0x1f5cff(_0x12ce6f);});},'afterCreate':function(_0x4092ed,_0x26a933,_0x49480c){var _0x2b8dca=getUserApplications(_0x4092ed,_0x4092ed[_0x438e('0x28')]);if(_0x4092ed[_0x438e('0x28')]!=_0x4092ed['name']){_0x2b8dca=_0x2b8dca[_0x438e('0x29')](getUserApplications(_0x4092ed,_0x4092ed[_0x438e('0x19')]));}return _0xf329aa['VoiceExtension'][_0x438e('0x36')](_0x2b8dca)[_0x438e('0x27')](function(){if(_0x4092ed[_0x438e('0x10')]){return getChanSpyPromise(_0xf329aa,_0x4092ed);}})[_0x438e('0x27')](function(_0x3aa92f){if(_0x3aa92f&&_0x3aa92f[_0x438e('0x5')]){return _0xf329aa[_0x438e('0x37')][_0x438e('0x36')](_0x3aa92f);}})[_0x438e('0x27')](function(){_0x49480c();})[_0x438e('0x2a')](function(_0x213c6d){_0x49480c(_0x213c6d);});},'afterUpdate':function(_0x160a06,_0x224093,_0x34ba25){return BPromise[_0x438e('0x38')]()[_0x438e('0x27')](function(){if(_0x160a06[_0x438e('0x35')](_0x438e('0x10'))||_0x160a06[_0x438e('0x35')](_0x438e('0x6'))){return _0xf329aa['VoiceExtension'][_0x438e('0x39')]({'where':{'UserId':_0x160a06['id'],'type':_0x438e('0x8'),'ChanSpyId':{'$ne':null}}})[_0x438e('0x27')](function(){if(_0x160a06[_0x438e('0x10')]){return getChanSpyPromise(_0xf329aa,_0x160a06)[_0x438e('0x27')](function(_0x48bb8b){if(_0x48bb8b&&_0x48bb8b['length']){return _0xf329aa[_0x438e('0x37')][_0x438e('0x36')](_0x48bb8b);}});}});}})[_0x438e('0x27')](function(){if(_0x160a06['changed'](_0x438e('0x1f'))||_0x160a06[_0x438e('0x35')]('context')){return _0xf329aa[_0x438e('0x37')][_0x438e('0x39')]({'where':{'UserId':_0x160a06['id'],'type':_0x438e('0x8'),'ChanSpyId':null}})[_0x438e('0x27')](function(){var _0xff8519=getUserApplications(_0x160a06,_0x160a06[_0x438e('0x28')]);if(_0x160a06[_0x438e('0x28')]!=_0x160a06['name']){_0xff8519=_0xff8519[_0x438e('0x29')](getUserApplications(_0x160a06,_0x160a06['name']));}return _0xf329aa[_0x438e('0x37')][_0x438e('0x36')](_0xff8519);});}})[_0x438e('0x27')](function(){_0x34ba25();})[_0x438e('0x2a')](function(_0x1ebcf8){_0x34ba25(_0x1ebcf8);});},'afterDestroy':function(_0x554c07,_0x31b929){return _0xf329aa[_0x438e('0x37')][_0x438e('0x39')]({'where':{'UserId':_0x554c07['id'],'type':_0x438e('0x8')}});}},'instanceMethods':{'authenticate':function(_0x317c31,_0x7f75f0){if(!_0x7f75f0){return this[_0x438e('0x16')]===this['encryptPassword'](_0x317c31);}var _0x556590=this;this[_0x438e('0x3a')](_0x317c31,function(_0x509aa0,_0x2efd44){if(_0x509aa0){_0x7f75f0(_0x509aa0);}if(_0x556590['password']===_0x2efd44){_0x7f75f0(null,!![]);}else{_0x7f75f0(null,![]);}});},'makeSalt':function(_0x1482ad,_0x5f22a8){var _0x52156b=0x10;if(typeof arguments[0x0]===_0x438e('0x3b')){_0x5f22a8=arguments[0x0];_0x1482ad=_0x52156b;}else if(typeof arguments[0x1]===_0x438e('0x3b')){_0x5f22a8=arguments[0x1];}else{throw new Error(_0x438e('0x3c'));}if(!_0x1482ad){_0x1482ad=_0x52156b;}return crypto[_0x438e('0x3d')](_0x1482ad,function(_0x53d405,_0x17a54e){if(_0x53d405){_0x5f22a8(_0x53d405);}return _0x5f22a8(null,_0x17a54e[_0x438e('0x3e')](_0x438e('0x3f')));});},'encryptPassword':function(_0x2861f7,_0x5c426a){if(!_0x2861f7||!this[_0x438e('0x40')]){return _0x5c426a?_0x5c426a(null):null;}var _0x11fc9a=0x2710;var _0xd97f73=0x40;var _0x16d839=new Buffer(this[_0x438e('0x40')],_0x438e('0x3f'));if(!_0x5c426a){return crypto['pbkdf2Sync'](_0x2861f7,_0x16d839,_0x11fc9a,_0xd97f73,_0x438e('0x41'))[_0x438e('0x3e')](_0x438e('0x3f'));}return crypto[_0x438e('0x42')](_0x2861f7,_0x16d839,_0x11fc9a,_0xd97f73,'sha1',function(_0x1c0f5a,_0x16f340){if(_0x1c0f5a){_0x5c426a(_0x1c0f5a);}return _0x5c426a(null,_0x16f340[_0x438e('0x3e')]('base64'));});},'updatePassword':function(_0x7c559f){if(!this[_0x438e('0x16')]){return _0x7c559f(null);}if(!validatePresenceOf(this[_0x438e('0x16')])&&authTypes['indexOf'](this[_0x438e('0x43')])===-0x1){_0x7c559f(new Error(_0x438e('0x44')));}var _0x32a197=this;this[_0x438e('0x45')](function(_0x1b2911,_0x13c5a0){if(_0x1b2911){return _0x7c559f(_0x1b2911);}_0x32a197[_0x438e('0x40')]=_0x13c5a0;_0x32a197['encryptPassword'](_0x32a197[_0x438e('0x16')],function(_0x46528b,_0x2b5758){if(_0x46528b){_0x7c559f(_0x46528b);}_0x32a197[_0x438e('0x16')]=_0x2b5758;_0x7c559f(null);});});},'updateMd5Password':function(){this[_0x438e('0x46')]=md5(this[_0x438e('0x19')]+_0x438e('0x47')+this[_0x438e('0x16')]);return this['md5secret'];}}});};
\ No newline at end of file