Built motion from commit caf7d5f0.|2.5.39
[motion2.git] / server / api / user / user.model.js
index f94db90..8d129da 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x54fb=['prefix','push','merge','format','CDR(type)=%s','chanspy','record','${UNIQUEID}.%s,a','recordingFormat','Authenticate','password','SIP/%s,%s','name','options','join','StopMixMonitor','wav','WAV','system','Set','CDR(type)=internal','includes','extensionMonitor','_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','_XCALLY_MIXMONITOR_FORMAT=%s','Dial','SIP/%s,,tTxX','Hangup','priority','defaults','VoiceChanSpy','findAll','internal','concat','models','define','User','users','utf8','utf8_bin','userProfileId','undefined','resolve','find','then','privacyEnabled','updateMd5Password','updatePassword','catch','changed','UserProfile','bulkCreate','VoiceExtension','destroy','encryptPassword','function','Missing\x20Callback','randomBytes','toString','base64','salt','pbkdf2Sync','sha1','pbkdf2','provider','Invalid\x20password','makeSalt',':asterisk:','md5secret','crypto','util','md5','./user.attributes','google','context','from-sip','length','%s%s'];(function(_0xb65e77,_0x238c3d){var _0x38134b=function(_0x39da21){while(--_0x39da21){_0xb65e77['push'](_0xb65e77['shift']());}};_0x38134b(++_0x238c3d);}(_0x54fb,0x93));var _0xb54f=function(_0x3cd7ac,_0x4c9361){_0x3cd7ac=_0x3cd7ac-0x0;var _0x56c00a=_0x54fb[_0x3cd7ac];return _0x56c00a;};'use strict';var BPromise=require('bluebird');var crypto=require(_0xb54f('0x0'));var util=require(_0xb54f('0x1'));var md5=require(_0xb54f('0x2'));var _=require('lodash');var attributes=require(_0xb54f('0x3'));var authTypes=[_0xb54f('0x4')];var validatePresenceOf=function(_0x115d6f){return _0x115d6f&&_0x115d6f['length'];};var getChanSpyApplications=function(_0x107456,_0x2f7728,_0x387e91){var _0x5391e4={'context':_0x107456[_0xb54f('0x5')]||_0xb54f('0x6'),'type':'system','isApp':![],'UserId':_0x107456['id']};var _0x290ca8=[];for(var _0x3c30d9=0x0,_0x40fe61=0x1;_0x3c30d9<_0x387e91[_0xb54f('0x7')];_0x3c30d9++,_0x40fe61=0x1){var _0x491472={'exten':util['format'](_0xb54f('0x8'),_0x387e91[_0x3c30d9][_0xb54f('0x9')],_0x2f7728),'ChanSpyId':_0x387e91[_0x3c30d9]['id']};_0x290ca8[_0xb54f('0xa')](_[_0xb54f('0xb')]({'app':'Set','appdata':util[_0xb54f('0xc')](_0xb54f('0xd'),_0xb54f('0xe')),'priority':_0x40fe61++},_0x5391e4,_0x491472));if(_0x387e91[_0x3c30d9][_0xb54f('0xf')]){_0x290ca8[_0xb54f('0xa')](_['merge']({'app':'MixMonitor','appdata':util[_0xb54f('0xc')](_0xb54f('0x10'),_0x387e91[_0x3c30d9][_0xb54f('0x11')]),'priority':_0x40fe61++},_0x5391e4,_0x491472));}if(_0x387e91[_0x3c30d9]['auth']){_0x290ca8[_0xb54f('0xa')](_[_0xb54f('0xb')]({'app':_0xb54f('0x12'),'appdata':_0x387e91[_0x3c30d9][_0xb54f('0x13')],'priority':_0x40fe61++},_0x5391e4,_0x491472));}_0x290ca8[_0xb54f('0xa')](_[_0xb54f('0xb')]({'app':'ChanSpy','appdata':util[_0xb54f('0xc')](_0xb54f('0x14'),_0x107456[_0xb54f('0x15')],_0x387e91[_0x3c30d9][_0xb54f('0x16')]?_0x387e91[_0x3c30d9][_0xb54f('0x16')][_0xb54f('0x17')](''):''),'priority':_0x40fe61++},_0x5391e4,_0x491472));if(_0x387e91[_0x3c30d9][_0xb54f('0xf')]){_0x290ca8['push'](_[_0xb54f('0xb')]({'app':_0xb54f('0x18'),'priority':_0x40fe61++},_0x5391e4,_0x491472));}}return _0x290ca8;};var getUserApplications=function(_0x35534a,_0x4df103){var _0x8efe41=[_0xb54f('0x19'),_0xb54f('0x1a'),'gsm'];var _0x5dea68={'context':_0x35534a[_0xb54f('0x5')]||_0xb54f('0x6'),'exten':_0x4df103,'type':_0xb54f('0x1b'),'isApp':![],'UserId':_0x35534a['id']};var _0x4772c1=[{'app':_0xb54f('0x1c'),'appdata':_0xb54f('0x1d')}];if(_0x35534a['extensionMonitor']&&_[_0xb54f('0x1e')](_0x8efe41,_0x35534a[_0xb54f('0x1f')])){_0x4772c1[_0xb54f('0xa')]({'app':_0xb54f('0x1c'),'appdata':_0xb54f('0x20')});_0x4772c1['push']({'app':_0xb54f('0x1c'),'appdata':util['format'](_0xb54f('0x21'),_0x35534a[_0xb54f('0x1f')])});_0x4772c1[_0xb54f('0xa')]({'app':_0xb54f('0x22'),'appdata':util[_0xb54f('0xc')]('SIP/%s,,tTxXU(xcally-mixmonitor-context)',_0x35534a[_0xb54f('0x15')])});}else{_0x4772c1[_0xb54f('0xa')]({'app':_0xb54f('0x22'),'appdata':util[_0xb54f('0xc')](_0xb54f('0x23'),_0x35534a[_0xb54f('0x15')])});}_0x4772c1[_0xb54f('0xa')]({'app':_0xb54f('0x24')});for(var _0x5476c4=0x0;_0x5476c4<_0x4772c1[_0xb54f('0x7')];_0x5476c4++){_0x4772c1[_0x5476c4][_0xb54f('0x25')]=_0x5476c4+0x1;_0x4772c1[_0x5476c4]=_[_0xb54f('0x26')](_0x4772c1[_0x5476c4],_0x5dea68);}return _0x4772c1;};var getChanSpyPromise=function(_0x5438f8,_0x520e93){return new BPromise(function(_0x79c1b3,_0x5a037b){return _0x5438f8[_0xb54f('0x27')][_0xb54f('0x28')]()['then'](function(_0x5a83ab){if(_0x5a83ab){var _0x16d999=getChanSpyApplications(_0x520e93,_0x520e93[_0xb54f('0x29')],_0x5a83ab);if(_0x520e93['internal']!=_0x520e93[_0xb54f('0x15')]){_0x16d999=_0x16d999[_0xb54f('0x2a')](getChanSpyApplications(_0x520e93,_0x520e93[_0xb54f('0x15')],_0x5a83ab));}return _0x79c1b3(_0x16d999);}return _0x79c1b3([]);})['catch'](function(_0x4470ab){_0x5a037b(_0x4470ab);});});};module['exports']=function(_0x4d424a,_0xd1191d){var _0x34fb88=_0x4d424a[_0xb54f('0x2b')];return _0x4d424a[_0xb54f('0x2c')](_0xb54f('0x2d'),attributes,{'tableName':_0xb54f('0x2e'),'charset':_0xb54f('0x2f'),'collate':_0xb54f('0x30'),'hooks':{'beforeCreate':function(_0x41e095,_0x49a070,_0x279ca5){var _0x3dea02=typeof _0x41e095[_0xb54f('0x31')]===_0xb54f('0x32')?BPromise[_0xb54f('0x33')](null):_0x34fb88['UserProfile'][_0xb54f('0x34')]({'where':{'id':_0x41e095[_0xb54f('0x31')]}});_0x3dea02[_0xb54f('0x35')](function(_0x4a47fc){if(_0x4a47fc){_0x41e095['privacyEnabled']=_0x4a47fc[_0xb54f('0x36')];}})[_0xb54f('0x35')](function(){_0x41e095[_0xb54f('0x37')]();_0x41e095[_0xb54f('0x38')](_0x279ca5);})[_0xb54f('0x39')](function(_0x30bccc){_0x279ca5(_0x30bccc);});},'beforeUpdate':function(_0x4a9b33,_0x5aa771,_0x21c455){Promise[_0xb54f('0x33')]()[_0xb54f('0x35')](function(){if(_0x4a9b33[_0xb54f('0x3a')](_0xb54f('0x31'))===![])return;return _0x34fb88[_0xb54f('0x3b')][_0xb54f('0x34')]({'where':{'id':_0x4a9b33[_0xb54f('0x31')]}})[_0xb54f('0x35')](function(_0x25eb13){if(_0x25eb13)_0x4a9b33[_0xb54f('0x36')]=_0x25eb13[_0xb54f('0x36')];return;});})[_0xb54f('0x35')](function(){if(_0x4a9b33[_0xb54f('0x3a')](_0xb54f('0x13'))){_0x4a9b33[_0xb54f('0x37')]();return _0x4a9b33[_0xb54f('0x38')](_0x21c455);}_0x21c455();})['catch'](function(_0x15c4e4){_0x21c455(_0x15c4e4);});},'afterCreate':function(_0x5a3a97,_0x4f0b53,_0x13fa50){var _0x4bbb63=getUserApplications(_0x5a3a97,_0x5a3a97[_0xb54f('0x29')]);if(_0x5a3a97[_0xb54f('0x29')]!=_0x5a3a97[_0xb54f('0x15')]){_0x4bbb63=_0x4bbb63[_0xb54f('0x2a')](getUserApplications(_0x5a3a97,_0x5a3a97[_0xb54f('0x15')]));}return _0x34fb88['VoiceExtension'][_0xb54f('0x3c')](_0x4bbb63)['then'](function(){if(_0x5a3a97[_0xb54f('0xe')]){return getChanSpyPromise(_0x34fb88,_0x5a3a97);}})['then'](function(_0x1144b1){if(_0x1144b1&&_0x1144b1[_0xb54f('0x7')]){return _0x34fb88['VoiceExtension'][_0xb54f('0x3c')](_0x1144b1);}})[_0xb54f('0x35')](function(){_0x13fa50();})['catch'](function(_0x1df79c){_0x13fa50(_0x1df79c);});},'afterUpdate':function(_0x5e57a7,_0x5de6f7,_0x3c4721){return BPromise['resolve']()[_0xb54f('0x35')](function(){if(_0x5e57a7[_0xb54f('0x3a')]('chanspy')||_0x5e57a7['changed'](_0xb54f('0x5'))){return _0x34fb88['VoiceExtension']['destroy']({'where':{'UserId':_0x5e57a7['id'],'type':_0xb54f('0x1b'),'ChanSpyId':{'$ne':null}}})['then'](function(){if(_0x5e57a7['chanspy']){return getChanSpyPromise(_0x34fb88,_0x5e57a7)[_0xb54f('0x35')](function(_0x2cb62a){if(_0x2cb62a&&_0x2cb62a[_0xb54f('0x7')]){return _0x34fb88[_0xb54f('0x3d')][_0xb54f('0x3c')](_0x2cb62a);}});}});}})['then'](function(){if(_0x5e57a7['changed'](_0xb54f('0x1f'))||_0x5e57a7[_0xb54f('0x3a')](_0xb54f('0x5'))){return _0x34fb88[_0xb54f('0x3d')][_0xb54f('0x3e')]({'where':{'UserId':_0x5e57a7['id'],'type':_0xb54f('0x1b'),'ChanSpyId':null}})[_0xb54f('0x35')](function(){var _0x5553b8=getUserApplications(_0x5e57a7,_0x5e57a7[_0xb54f('0x29')]);if(_0x5e57a7[_0xb54f('0x29')]!=_0x5e57a7[_0xb54f('0x15')]){_0x5553b8=_0x5553b8['concat'](getUserApplications(_0x5e57a7,_0x5e57a7[_0xb54f('0x15')]));}return _0x34fb88[_0xb54f('0x3d')][_0xb54f('0x3c')](_0x5553b8);});}})[_0xb54f('0x35')](function(){_0x3c4721();})[_0xb54f('0x39')](function(_0x5c23c1){_0x3c4721(_0x5c23c1);});},'afterDestroy':function(_0x118d10,_0x349a52){return _0x34fb88[_0xb54f('0x3d')][_0xb54f('0x3e')]({'where':{'UserId':_0x118d10['id'],'type':_0xb54f('0x1b')}});}},'instanceMethods':{'authenticate':function(_0x1e8211,_0x97e9d2){if(!_0x97e9d2){return this[_0xb54f('0x13')]===this[_0xb54f('0x3f')](_0x1e8211);}var _0x59b35b=this;this[_0xb54f('0x3f')](_0x1e8211,function(_0x448613,_0x59de74){if(_0x448613){_0x97e9d2(_0x448613);}if(_0x59b35b['password']===_0x59de74){_0x97e9d2(null,!![]);}else{_0x97e9d2(null,![]);}});},'makeSalt':function(_0x447f35,_0x5539a2){var _0x30832b=0x10;if(typeof arguments[0x0]==='function'){_0x5539a2=arguments[0x0];_0x447f35=_0x30832b;}else if(typeof arguments[0x1]===_0xb54f('0x40')){_0x5539a2=arguments[0x1];}else{throw new Error(_0xb54f('0x41'));}if(!_0x447f35){_0x447f35=_0x30832b;}return crypto[_0xb54f('0x42')](_0x447f35,function(_0xec048e,_0x5aa0bb){if(_0xec048e){_0x5539a2(_0xec048e);}return _0x5539a2(null,_0x5aa0bb[_0xb54f('0x43')](_0xb54f('0x44')));});},'encryptPassword':function(_0x2b8261,_0x465ca8){if(!_0x2b8261||!this[_0xb54f('0x45')]){return _0x465ca8?_0x465ca8(null):null;}var _0x24bf70=0x2710;var _0x3f81ba=0x40;var _0x48a935=new Buffer(this[_0xb54f('0x45')],_0xb54f('0x44'));if(!_0x465ca8){return crypto[_0xb54f('0x46')](_0x2b8261,_0x48a935,_0x24bf70,_0x3f81ba,_0xb54f('0x47'))['toString'](_0xb54f('0x44'));}return crypto[_0xb54f('0x48')](_0x2b8261,_0x48a935,_0x24bf70,_0x3f81ba,_0xb54f('0x47'),function(_0xd01789,_0x474977){if(_0xd01789){_0x465ca8(_0xd01789);}return _0x465ca8(null,_0x474977[_0xb54f('0x43')](_0xb54f('0x44')));});},'updatePassword':function(_0x60f82a){if(!this[_0xb54f('0x13')]){return _0x60f82a(null);}if(!validatePresenceOf(this[_0xb54f('0x13')])&&authTypes['indexOf'](this[_0xb54f('0x49')])===-0x1){_0x60f82a(new Error(_0xb54f('0x4a')));}var _0x59e144=this;this[_0xb54f('0x4b')](function(_0x30782f,_0x43c6ab){if(_0x30782f){return _0x60f82a(_0x30782f);}_0x59e144[_0xb54f('0x45')]=_0x43c6ab;_0x59e144[_0xb54f('0x3f')](_0x59e144[_0xb54f('0x13')],function(_0x5f098c,_0xdb278e){if(_0x5f098c){_0x60f82a(_0x5f098c);}_0x59e144[_0xb54f('0x13')]=_0xdb278e;_0x60f82a(null);});});},'updateMd5Password':function(){this['md5secret']=md5(this[_0xb54f('0x15')]+_0xb54f('0x4c')+this['password']);return this[_0xb54f('0x4d')];}}});};
\ No newline at end of file
+var _0x2d1b=['find','privacyEnabled','then','updateMd5Password','updatePassword','changed','password','concat','VoiceExtension','bulkCreate','chanspy','destroy','encryptPassword','function','Missing\x20Callback','base64','salt','pbkdf2Sync','sha1','toString','pbkdf2','provider','md5secret',':asterisk:','crypto','md5','lodash','./user.attributes','length','context','from-sip','system','%s%s','prefix','push','merge','format','CDR(type)=%s','record','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','Authenticate','SIP/%s,%s','options','join','StopMixMonitor','wav','WAV','gsm','Set','CDR(type)=internal','includes','extensionMonitor','_XCALLY_MIXMONITOR_FORMAT=%s','Dial','name','SIP/%s,,tTxX','priority','defaults','VoiceChanSpy','findAll','internal','catch','exports','models','define','User','users','utf8_bin','userProfileId','undefined','resolve','UserProfile'];(function(_0x92f543,_0x596ba0){var _0xefc2d3=function(_0x221d59){while(--_0x221d59){_0x92f543['push'](_0x92f543['shift']());}};_0xefc2d3(++_0x596ba0);}(_0x2d1b,0xf6));var _0xb2d1=function(_0x45dfb0,_0x122bd9){_0x45dfb0=_0x45dfb0-0x0;var _0x898a26=_0x2d1b[_0x45dfb0];return _0x898a26;};'use strict';var BPromise=require('bluebird');var crypto=require(_0xb2d1('0x0'));var util=require('util');var md5=require(_0xb2d1('0x1'));var _=require(_0xb2d1('0x2'));var attributes=require(_0xb2d1('0x3'));var authTypes=['google'];var validatePresenceOf=function(_0x113197){return _0x113197&&_0x113197[_0xb2d1('0x4')];};var getChanSpyApplications=function(_0x180052,_0x3b8be6,_0x2b69d3){var _0x4d9607={'context':_0x180052[_0xb2d1('0x5')]||_0xb2d1('0x6'),'type':_0xb2d1('0x7'),'isApp':![],'UserId':_0x180052['id']};var _0x2b0f5d=[];for(var _0x1a7cd1=0x0,_0x1e8e7c=0x1;_0x1a7cd1<_0x2b69d3['length'];_0x1a7cd1++,_0x1e8e7c=0x1){var _0x23e7c6={'exten':util['format'](_0xb2d1('0x8'),_0x2b69d3[_0x1a7cd1][_0xb2d1('0x9')],_0x3b8be6),'ChanSpyId':_0x2b69d3[_0x1a7cd1]['id']};_0x2b0f5d[_0xb2d1('0xa')](_[_0xb2d1('0xb')]({'app':'Set','appdata':util[_0xb2d1('0xc')](_0xb2d1('0xd'),'chanspy'),'priority':_0x1e8e7c++},_0x4d9607,_0x23e7c6));if(_0x2b69d3[_0x1a7cd1][_0xb2d1('0xe')]){_0x2b0f5d['push'](_['merge']({'app':_0xb2d1('0xf'),'appdata':util[_0xb2d1('0xc')](_0xb2d1('0x10'),_0x2b69d3[_0x1a7cd1][_0xb2d1('0x11')]),'priority':_0x1e8e7c++},_0x4d9607,_0x23e7c6));}if(_0x2b69d3[_0x1a7cd1]['auth']){_0x2b0f5d[_0xb2d1('0xa')](_[_0xb2d1('0xb')]({'app':_0xb2d1('0x12'),'appdata':_0x2b69d3[_0x1a7cd1]['password'],'priority':_0x1e8e7c++},_0x4d9607,_0x23e7c6));}_0x2b0f5d['push'](_['merge']({'app':'ChanSpy','appdata':util[_0xb2d1('0xc')](_0xb2d1('0x13'),_0x180052['name'],_0x2b69d3[_0x1a7cd1][_0xb2d1('0x14')]?_0x2b69d3[_0x1a7cd1][_0xb2d1('0x14')][_0xb2d1('0x15')](''):''),'priority':_0x1e8e7c++},_0x4d9607,_0x23e7c6));if(_0x2b69d3[_0x1a7cd1][_0xb2d1('0xe')]){_0x2b0f5d[_0xb2d1('0xa')](_[_0xb2d1('0xb')]({'app':_0xb2d1('0x16'),'priority':_0x1e8e7c++},_0x4d9607,_0x23e7c6));}}return _0x2b0f5d;};var getUserApplications=function(_0x644e84,_0x25686f){var _0x4cf944=[_0xb2d1('0x17'),_0xb2d1('0x18'),_0xb2d1('0x19')];var _0x3fd982={'context':_0x644e84[_0xb2d1('0x5')]||'from-sip','exten':_0x25686f,'type':_0xb2d1('0x7'),'isApp':![],'UserId':_0x644e84['id']};var _0x3146b0=[{'app':_0xb2d1('0x1a'),'appdata':_0xb2d1('0x1b')}];if(_0x644e84['extensionMonitor']&&_[_0xb2d1('0x1c')](_0x4cf944,_0x644e84[_0xb2d1('0x1d')])){_0x3146b0[_0xb2d1('0xa')]({'app':_0xb2d1('0x1a'),'appdata':'_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}'});_0x3146b0['push']({'app':_0xb2d1('0x1a'),'appdata':util[_0xb2d1('0xc')](_0xb2d1('0x1e'),_0x644e84[_0xb2d1('0x1d')])});_0x3146b0[_0xb2d1('0xa')]({'app':_0xb2d1('0x1f'),'appdata':util[_0xb2d1('0xc')]('SIP/%s,,tTxXU(xcally-mixmonitor-context)',_0x644e84[_0xb2d1('0x20')])});}else{_0x3146b0[_0xb2d1('0xa')]({'app':_0xb2d1('0x1f'),'appdata':util[_0xb2d1('0xc')](_0xb2d1('0x21'),_0x644e84[_0xb2d1('0x20')])});}_0x3146b0[_0xb2d1('0xa')]({'app':'Hangup'});for(var _0x523183=0x0;_0x523183<_0x3146b0[_0xb2d1('0x4')];_0x523183++){_0x3146b0[_0x523183][_0xb2d1('0x22')]=_0x523183+0x1;_0x3146b0[_0x523183]=_[_0xb2d1('0x23')](_0x3146b0[_0x523183],_0x3fd982);}return _0x3146b0;};var getChanSpyPromise=function(_0x5891da,_0x575066){return new BPromise(function(_0x28b445,_0x4e1aee){return _0x5891da[_0xb2d1('0x24')][_0xb2d1('0x25')]()['then'](function(_0x4d1334){if(_0x4d1334){var _0x492d73=getChanSpyApplications(_0x575066,_0x575066['internal'],_0x4d1334);if(_0x575066[_0xb2d1('0x26')]!=_0x575066[_0xb2d1('0x20')]){_0x492d73=_0x492d73['concat'](getChanSpyApplications(_0x575066,_0x575066['name'],_0x4d1334));}return _0x28b445(_0x492d73);}return _0x28b445([]);})[_0xb2d1('0x27')](function(_0x5ca826){_0x4e1aee(_0x5ca826);});});};module[_0xb2d1('0x28')]=function(_0x566bf8,_0x343707){var _0x2a7568=_0x566bf8[_0xb2d1('0x29')];return _0x566bf8[_0xb2d1('0x2a')](_0xb2d1('0x2b'),attributes,{'tableName':_0xb2d1('0x2c'),'charset':'utf8','collate':_0xb2d1('0x2d'),'hooks':{'beforeCreate':function(_0x75819a,_0x311175,_0x4caa81){var _0x57f4d0=typeof _0x75819a[_0xb2d1('0x2e')]===_0xb2d1('0x2f')?BPromise[_0xb2d1('0x30')](null):_0x2a7568[_0xb2d1('0x31')][_0xb2d1('0x32')]({'where':{'id':_0x75819a[_0xb2d1('0x2e')]}});_0x57f4d0['then'](function(_0x444082){if(_0x444082){_0x75819a[_0xb2d1('0x33')]=_0x444082['privacyEnabled'];}})[_0xb2d1('0x34')](function(){_0x75819a[_0xb2d1('0x35')]();_0x75819a[_0xb2d1('0x36')](_0x4caa81);})[_0xb2d1('0x27')](function(_0x4169fc){_0x4caa81(_0x4169fc);});},'beforeUpdate':function(_0x26b84c,_0x5ca1cf,_0x2e4e36){Promise[_0xb2d1('0x30')]()[_0xb2d1('0x34')](function(){if(_0x26b84c[_0xb2d1('0x37')]('userProfileId')===![])return;return _0x2a7568[_0xb2d1('0x31')]['find']({'where':{'id':_0x26b84c[_0xb2d1('0x2e')]}})[_0xb2d1('0x34')](function(_0x23f766){if(_0x23f766)_0x26b84c[_0xb2d1('0x33')]=_0x23f766[_0xb2d1('0x33')];return;});})[_0xb2d1('0x34')](function(){if(_0x26b84c[_0xb2d1('0x37')](_0xb2d1('0x38'))){_0x26b84c['updateMd5Password']();return _0x26b84c['updatePassword'](_0x2e4e36);}_0x2e4e36();})[_0xb2d1('0x27')](function(_0x51acc2){_0x2e4e36(_0x51acc2);});},'afterCreate':function(_0x14b03b,_0x153314,_0x260eec){var _0x47f443=getUserApplications(_0x14b03b,_0x14b03b[_0xb2d1('0x26')]);if(_0x14b03b['internal']!=_0x14b03b[_0xb2d1('0x20')]){_0x47f443=_0x47f443[_0xb2d1('0x39')](getUserApplications(_0x14b03b,_0x14b03b['name']));}return _0x2a7568['VoiceExtension']['bulkCreate'](_0x47f443)['then'](function(){if(_0x14b03b['chanspy']){return getChanSpyPromise(_0x2a7568,_0x14b03b);}})['then'](function(_0x2ce219){if(_0x2ce219&&_0x2ce219[_0xb2d1('0x4')]){return _0x2a7568[_0xb2d1('0x3a')][_0xb2d1('0x3b')](_0x2ce219);}})[_0xb2d1('0x34')](function(){_0x260eec();})[_0xb2d1('0x27')](function(_0x1aa003){_0x260eec(_0x1aa003);});},'afterUpdate':function(_0x208445,_0x3bb30c,_0x1a3f08){return BPromise['resolve']()[_0xb2d1('0x34')](function(){if(_0x208445[_0xb2d1('0x37')](_0xb2d1('0x3c'))||_0x208445['changed'](_0xb2d1('0x5'))){return _0x2a7568[_0xb2d1('0x3a')][_0xb2d1('0x3d')]({'where':{'UserId':_0x208445['id'],'type':_0xb2d1('0x7'),'ChanSpyId':{'$ne':null}}})['then'](function(){if(_0x208445[_0xb2d1('0x3c')]){return getChanSpyPromise(_0x2a7568,_0x208445)[_0xb2d1('0x34')](function(_0x598522){if(_0x598522&&_0x598522[_0xb2d1('0x4')]){return _0x2a7568[_0xb2d1('0x3a')][_0xb2d1('0x3b')](_0x598522);}});}});}})[_0xb2d1('0x34')](function(){if(_0x208445[_0xb2d1('0x37')](_0xb2d1('0x1d'))||_0x208445[_0xb2d1('0x37')](_0xb2d1('0x5'))){return _0x2a7568[_0xb2d1('0x3a')][_0xb2d1('0x3d')]({'where':{'UserId':_0x208445['id'],'type':'system','ChanSpyId':null}})[_0xb2d1('0x34')](function(){var _0x23f085=getUserApplications(_0x208445,_0x208445[_0xb2d1('0x26')]);if(_0x208445[_0xb2d1('0x26')]!=_0x208445['name']){_0x23f085=_0x23f085['concat'](getUserApplications(_0x208445,_0x208445[_0xb2d1('0x20')]));}return _0x2a7568[_0xb2d1('0x3a')][_0xb2d1('0x3b')](_0x23f085);});}})['then'](function(){_0x1a3f08();})[_0xb2d1('0x27')](function(_0x1ea6c2){_0x1a3f08(_0x1ea6c2);});},'afterDestroy':function(_0x456e37,_0x33cfc9){return _0x2a7568['VoiceExtension'][_0xb2d1('0x3d')]({'where':{'UserId':_0x456e37['id'],'type':_0xb2d1('0x7')}});}},'instanceMethods':{'authenticate':function(_0x6c35d7,_0x276209){if(!_0x276209){return this[_0xb2d1('0x38')]===this[_0xb2d1('0x3e')](_0x6c35d7);}var _0x1c1cd9=this;this[_0xb2d1('0x3e')](_0x6c35d7,function(_0x172363,_0x88bb3a){if(_0x172363){_0x276209(_0x172363);}if(_0x1c1cd9[_0xb2d1('0x38')]===_0x88bb3a){_0x276209(null,!![]);}else{_0x276209(null,![]);}});},'makeSalt':function(_0x17d44d,_0x6cbbc4){var _0x41729d=0x10;if(typeof arguments[0x0]===_0xb2d1('0x3f')){_0x6cbbc4=arguments[0x0];_0x17d44d=_0x41729d;}else if(typeof arguments[0x1]==='function'){_0x6cbbc4=arguments[0x1];}else{throw new Error(_0xb2d1('0x40'));}if(!_0x17d44d){_0x17d44d=_0x41729d;}return crypto['randomBytes'](_0x17d44d,function(_0xab58f9,_0x851d8a){if(_0xab58f9){_0x6cbbc4(_0xab58f9);}return _0x6cbbc4(null,_0x851d8a['toString'](_0xb2d1('0x41')));});},'encryptPassword':function(_0xda9524,_0x13f4e1){if(!_0xda9524||!this['salt']){return _0x13f4e1?_0x13f4e1(null):null;}var _0x313627=0x2710;var _0x3e619c=0x40;var _0x1f3f7e=new Buffer(this[_0xb2d1('0x42')],'base64');if(!_0x13f4e1){return crypto[_0xb2d1('0x43')](_0xda9524,_0x1f3f7e,_0x313627,_0x3e619c,_0xb2d1('0x44'))[_0xb2d1('0x45')](_0xb2d1('0x41'));}return crypto[_0xb2d1('0x46')](_0xda9524,_0x1f3f7e,_0x313627,_0x3e619c,'sha1',function(_0x1615d4,_0x31f890){if(_0x1615d4){_0x13f4e1(_0x1615d4);}return _0x13f4e1(null,_0x31f890[_0xb2d1('0x45')](_0xb2d1('0x41')));});},'updatePassword':function(_0x41f503){if(!this[_0xb2d1('0x38')]){return _0x41f503(null);}if(!validatePresenceOf(this[_0xb2d1('0x38')])&&authTypes['indexOf'](this[_0xb2d1('0x47')])===-0x1){_0x41f503(new Error('Invalid\x20password'));}var _0x269353=this;this['makeSalt'](function(_0x564589,_0x10dc11){if(_0x564589){return _0x41f503(_0x564589);}_0x269353[_0xb2d1('0x42')]=_0x10dc11;_0x269353[_0xb2d1('0x3e')](_0x269353[_0xb2d1('0x38')],function(_0x4b5d75,_0x21b128){if(_0x4b5d75){_0x41f503(_0x4b5d75);}_0x269353['password']=_0x21b128;_0x41f503(null);});});},'updateMd5Password':function(){this[_0xb2d1('0x48')]=md5(this[_0xb2d1('0x20')]+_0xb2d1('0x49')+this[_0xb2d1('0x38')]);return this[_0xb2d1('0x48')];}}});};
\ No newline at end of file