Built motion from commit 37e1ed56.|2.6.29
[motion2.git] / server / api / authLocal / authLocal.controller.js
index 7306803..3e02169 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2136=['Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','minutes','clearBlockUser','blockedAt','add','getLicense','catch','MailAccount','find','email','Smtp','CloudProvider','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','getSmtpOptions','merge','format','\x22%s\x22\x20<%s>','request','error','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','stringify','status','send','message','local-login','Something\x20went\x20wrong,\x20please\x20try\x20again.','role','signToken','json','body','Email\x20parameter\x20is\x20missing','generate','trim','toLowerCase','This\x20email\x20is\x20not\x20registered.','The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.','The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.','resetPasswordToken','resetPasswordExpires','now','save','xCally\x20Motion\x20Password\x20Reset','Please\x20click\x20on\x20the\x20following\x20link,\x20or\x20paste\x20this\x20into\x20your\x20browser\x20to\x20complete\x20the\x20process:\x0a\x0a','https://','headers','host','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','Reset\x20Email\x20sent!','User','params','token','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','securePassword','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','password','previousPasswords','validatePasswordHistory','Password\x20reset!','use','util','passport','passport-local','Strategy','lodash','randomstring','moment','../../mysqldb','../../components/auth/service','../../config/utils','client','http','Setting','findOne','allowedLoginAttempts','blockDuration','then','name','salt','blocked','loginAttempts','admin','user','agent','authenticate','disabled'];(function(_0x3255ae,_0x279cff){var _0x122d95=function(_0x65cac5){while(--_0x65cac5){_0x3255ae['push'](_0x3255ae['shift']());}};_0x122d95(++_0x279cff);}(_0x2136,0x96));var _0x6213=function(_0x101d5b,_0x40cfd){_0x101d5b=_0x101d5b-0x0;var _0x382a50=_0x2136[_0x101d5b];return _0x382a50;};'use strict';var util=require(_0x6213('0x0'));var passport=require(_0x6213('0x1'));var LocalStrategy=require(_0x6213('0x2'))[_0x6213('0x3')];var jayson=require('jayson/promise');var _=require(_0x6213('0x4'));var rs=require(_0x6213('0x5'));var moment=require(_0x6213('0x6'));var db=require(_0x6213('0x7'))['db'];var authService=require(_0x6213('0x8'));var utils=require(_0x6213('0x9'));var client=jayson[_0x6213('0xa')][_0x6213('0xb')]({'port':0x232b});function localAuthenticate(_0x27ed91,_0x53c82f,_0x7bc4b4,_0x2c8df1){var _0x505102,_0x1d84f5;return db[_0x6213('0xc')][_0x6213('0xd')]({'where':{'id':0x1},'attributes':[_0x6213('0xe'),_0x6213('0xf')],'raw':!![]})[_0x6213('0x10')](function(_0x1af751){_0x505102=_0x1af751;return _0x27ed91[_0x6213('0xd')]({'attributes':['id',_0x6213('0x11'),'password',_0x6213('0x12'),'role','disabled',_0x6213('0x13'),'blockedAt',_0x6213('0x14')],'where':{'name':_0x53c82f,'role':{'$or':[_0x6213('0x15'),_0x6213('0x16'),_0x6213('0x17')]}}});})['then'](function(_0x307c7b){if(!_0x307c7b||_0x307c7b&&_0x307c7b[_0x6213('0x11')]!==_0x53c82f){throw new Error('Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.');}else{_0x1d84f5=_0x307c7b;return _0x1d84f5;}})['then'](function(){_0x1d84f5[_0x6213('0x18')](_0x7bc4b4,function(_0x518fa0,_0xf0dd9){var _0x19e4fe=_0x1d84f5[_0x6213('0x14')]+0x1;if(_0x518fa0){return _0x2c8df1(_0x518fa0);}else if(!_0xf0dd9){if(_0x1d84f5[_0x6213('0x19')]){return _0x2c8df1(null,![],{'message':_0x6213('0x1a')});}else if(_0x505102[_0x6213('0xe')]>0x0){if(_0x1d84f5[_0x6213('0x13')]){if(_0x505102[_0x6213('0xf')]>0x0){if(moment(_0x1d84f5['blockedAt'])['add'](_0x505102[_0x6213('0xf')],_0x6213('0x1b'))>moment()){return _0x2c8df1(null,![],{'message':_0x6213('0x1a')});}else{return utils[_0x6213('0x1c')](_0x1d84f5,_0x19e4fe,![],null)['then'](function(){return _0x2c8df1(null,![],{'message':_0x6213('0x1a')});});}}else{return _0x2c8df1(null,![],{'message':_0x6213('0x1a')});}}else{if(_0x19e4fe>=_0x505102[_0x6213('0xe')]){return utils[_0x6213('0x1c')](_0x1d84f5,0x0,!![],moment())[_0x6213('0x10')](function(){return _0x2c8df1(null,![],{'message':_0x6213('0x1a')});});}else{return utils[_0x6213('0x1c')](_0x1d84f5,_0x19e4fe,![],null)['then'](function(){return _0x2c8df1(null,![],{'message':_0x6213('0x1a')});});}}}else{return _0x2c8df1(null,![],{'message':_0x6213('0x1a')});}}else{if(_0x1d84f5[_0x6213('0x19')]){return _0x2c8df1(null,![],{'message':_0x6213('0x1a')});}else if(_0x505102[_0x6213('0xe')]>0x0){if(_0x1d84f5[_0x6213('0x13')]){if(_0x505102[_0x6213('0xf')]>0x0){if(moment(_0x1d84f5[_0x6213('0x1d')])[_0x6213('0x1e')](_0x505102[_0x6213('0xf')],_0x6213('0x1b'))>moment()){return _0x2c8df1(null,![],{'message':_0x6213('0x1a')});}else{return utils[_0x6213('0x1c')](_0x1d84f5,0x0,![],null)[_0x6213('0x10')](function(){return utils[_0x6213('0x1f')](_0x1d84f5);})[_0x6213('0x10')](function(){return _0x2c8df1(null,_0x1d84f5);});}}else{return _0x2c8df1(null,![],{'message':_0x6213('0x1a')});}}else{return utils['clearBlockUser'](_0x1d84f5,0x0,![],null)[_0x6213('0x10')](function(){return utils[_0x6213('0x1f')](_0x1d84f5);})['then'](function(){return _0x2c8df1(null,_0x1d84f5);})['catch'](function(_0x50142b){return _0x2c8df1(null,![],_0x50142b);});}}else{if(_0x1d84f5[_0x6213('0x13')]){return _0x2c8df1(null,![],{'message':_0x6213('0x1a')});}else{return utils[_0x6213('0x1f')](_0x1d84f5)[_0x6213('0x10')](function(){return _0x2c8df1(null,_0x1d84f5);});}}}});})[_0x6213('0x20')](function(_0x2c3ebf){return _0x2c8df1(null,![],_0x2c3ebf);});}function sendServiceMail(_0x1068f3){return db[_0x6213('0x21')][_0x6213('0x22')]({'where':{'service':!![]},'attributes':['id',_0x6213('0x11'),_0x6213('0x23')],'include':[{'model':db['MailServerOut'],'as':_0x6213('0x24'),'include':[{'model':db[_0x6213('0x25')],'as':_0x6213('0x25')}]}]})[_0x6213('0x10')](function(_0x3dd062){if(!_0x3dd062){throw new Error(_0x6213('0x26'));}var _0xf35162=_0x3dd062[_0x6213('0x27')]();var _0x3dcb89={'account':_0xf35162,'message':_[_0x6213('0x28')]({'from':util[_0x6213('0x29')](_0x6213('0x2a'),_0x3dd062[_0x6213('0x11')],_0x3dd062[_0x6213('0x23')]||_0x3dd062[_0x6213('0x24')][_0x6213('0x16')])},_0x1068f3)};return client[_0x6213('0x2b')]('SendMail',_0x3dcb89);})['then'](function(_0x36317f){if(_0x36317f[_0x6213('0x2c')]){throw new Error(util[_0x6213('0x29')](_0x6213('0x2d'),_0x36317f['error']['message']||JSON[_0x6213('0x2e')](_0x36317f[_0x6213('0x2c')])));}return!![];});}function handleError(_0x1d9d1b,_0x4d9e85,_0x47cde3){return _0x1d9d1b[_0x6213('0x2f')](_0x4d9e85||0x1f4)[_0x6213('0x30')]({'message':_0x47cde3?_0x47cde3[_0x6213('0x31')]||_0x47cde3:''});}exports['login']=function(_0x2abfca,_0x27a262,_0x1f679c){passport[_0x6213('0x18')](_0x6213('0x32'),function(_0x3162d0,_0x43d17e,_0x100921){var _0x53ad34=_0x3162d0||_0x100921;if(_0x53ad34){return handleError(_0x27a262,0x191,_0x53ad34);}if(!_0x43d17e){return handleError(_0x27a262,0x194,{'message':_0x6213('0x33')});}else{var _0x1951e1={'payload':{'id':_0x43d17e['id'],'role':_0x43d17e[_0x6213('0x34')]},'options':{'expiresIn':0x15180}};return authService[_0x6213('0x35')](_0x1951e1)[_0x6213('0x10')](function(_0x48719a){_0x27a262[_0x6213('0x36')]({'id':_0x43d17e['id'],'token':_0x48719a,'statusCall':'','isAlreadyLogged':_0x43d17e['online']});});}})(_0x2abfca,_0x27a262,_0x1f679c);};exports['forgot']=function(_0x128d46,_0x999504){if(!_0x128d46[_0x6213('0x37')][_0x6213('0x23')]){return handleError(_0x999504,0x1f4,{'message':_0x6213('0x38')});}var _0x1435f9=rs[_0x6213('0x39')]();_0x128d46[_0x6213('0x37')][_0x6213('0x23')]=_0x128d46[_0x6213('0x37')][_0x6213('0x23')][_0x6213('0x3a')]()[_0x6213('0x3b')]();var _0x127f20;return db[_0x6213('0xc')][_0x6213('0xd')]({'where':{'id':0x1},'attributes':['allowedLoginAttempts',_0x6213('0xf')],'raw':!![]})['then'](function(_0x34aaa9){_0x127f20=_0x34aaa9;return db['User'][_0x6213('0x22')]({'where':{'email':_0x128d46[_0x6213('0x37')][_0x6213('0x23')]}});})['then'](function(_0x1e4312){if(!_0x1e4312){throw new Error(_0x6213('0x3c'));}if(_0x1e4312[_0x6213('0x19')]){throw new Error(_0x6213('0x3d'));}if(_0x1e4312[_0x6213('0x13')]){if(moment(_0x1e4312['blockedAt'])[_0x6213('0x1e')](_0x127f20[_0x6213('0xf')],'minutes')>moment()){throw new Error(_0x6213('0x3e'));}else{_0x1e4312[_0x6213('0x13')]=![];_0x1e4312[_0x6213('0x1d')]=null;}}_0x1e4312[_0x6213('0x3f')]=_0x1435f9;_0x1e4312[_0x6213('0x40')]=Date[_0x6213('0x41')]()+0x36ee80;return _0x1e4312[_0x6213('0x42')]();})['then'](function(){return sendServiceMail({'to':_0x128d46[_0x6213('0x37')][_0x6213('0x23')],'subject':_0x6213('0x43'),'text':'You\x20are\x20receiving\x20this\x20because\x20you\x20(or\x20someone\x20else)\x20have\x20requested\x20the\x20reset\x20of\x20the\x20password\x20for\x20your\x20account.\x0a\x0a'+_0x6213('0x44')+_0x6213('0x45')+_0x128d46[_0x6213('0x46')][_0x6213('0x47')]+_0x6213('0x48')+_0x1435f9+'\x0a\x0a'+_0x6213('0x49')});})[_0x6213('0x10')](function(){_0x999504[_0x6213('0x2f')](0xc8)['send']({'message':_0x6213('0x4a')});})[_0x6213('0x20')](function(_0x2dbdda){return handleError(_0x999504,0x1f4,_0x2dbdda);});};exports['reset']=function(_0x28dd66,_0x3f3b4b){return db[_0x6213('0x4b')][_0x6213('0x22')]({'where':{'resetPasswordToken':_0x28dd66[_0x6213('0x4c')][_0x6213('0x4d')],'resetPasswordExpires':{'$gt':Date[_0x6213('0x41')]()}}})[_0x6213('0x10')](function(_0x2892d8){if(!_0x2892d8){throw new Error(_0x6213('0x4e'));}return db[_0x6213('0xc')][_0x6213('0xd')]({'attributes':['id',_0x6213('0x4f'),_0x6213('0x50'),_0x6213('0x51')]})['then'](function(_0x1a6b35){if(_0x1a6b35[_0x6213('0x4f')])authService[_0x6213('0x52')](_0x28dd66[_0x6213('0x37')][_0x6213('0x53')]);if(!_0x1a6b35[_0x6213('0x50')]||!_0x2892d8[_0x6213('0x54')])return _0x2892d8;authService[_0x6213('0x55')](_0x28dd66[_0x6213('0x37')][_0x6213('0x53')],_0x2892d8[_0x6213('0x54')],_0x1a6b35[_0x6213('0x51')]);return _0x2892d8;})[_0x6213('0x10')](function(){_0x2892d8[_0x6213('0x53')]=_0x28dd66[_0x6213('0x37')][_0x6213('0x53')];_0x2892d8[_0x6213('0x3f')]=null;_0x2892d8[_0x6213('0x40')]=null;return _0x2892d8[_0x6213('0x42')]();});})[_0x6213('0x10')](function(){_0x3f3b4b[_0x6213('0x2f')](0xc8)[_0x6213('0x30')]({'message':_0x6213('0x56')});})[_0x6213('0x20')](function(_0x274ad3){return handleError(_0x3f3b4b,0x1f4,_0x274ad3);});};passport[_0x6213('0x57')](_0x6213('0x32'),new LocalStrategy({'usernameField':_0x6213('0x11'),'passwordField':_0x6213('0x53')},function(_0xe3bb4a,_0x768ece,_0x3d7880){return localAuthenticate(db[_0x6213('0x4b')],_0xe3bb4a,_0x768ece,_0x3d7880);}));
\ No newline at end of file
+var _0x844f=['allowedLoginAttempts','blockDuration','then','name','password','salt','role','disabled','loginAttempts','admin','user','agent','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','authenticate','blockedAt','add','minutes','clearBlockUser','blocked','getLicense','catch','MailAccount','find','email','Smtp','CloudProvider','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','merge','format','\x22%s\x22\x20<%s>','request','error','message','stringify','send','login','signToken','json','online','forgot','body','Email\x20parameter\x20is\x20missing','trim','toLowerCase','User','The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.','resetPasswordToken','resetPasswordExpires','now','save','Please\x20click\x20on\x20the\x20following\x20link,\x20or\x20paste\x20this\x20into\x20your\x20browser\x20to\x20complete\x20the\x20process:\x0a\x0a','headers','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','status','token','enforcePasswordHistory','securePassword','previousPasswords','validatePasswordHistory','passwordHistoryLimit','use','util','passport','Strategy','lodash','moment','../../mysqldb','../../components/auth/service','../../config/utils','client','http','Setting','findOne'];(function(_0x2457f6,_0x1306c5){var _0x48a590=function(_0x2a3f62){while(--_0x2a3f62){_0x2457f6['push'](_0x2457f6['shift']());}};_0x48a590(++_0x1306c5);}(_0x844f,0x166));var _0xf844=function(_0x205123,_0x240ebe){_0x205123=_0x205123-0x0;var _0x5b69fb=_0x844f[_0x205123];return _0x5b69fb;};'use strict';var util=require(_0xf844('0x0'));var passport=require(_0xf844('0x1'));var LocalStrategy=require('passport-local')[_0xf844('0x2')];var jayson=require('jayson/promise');var _=require(_0xf844('0x3'));var rs=require('randomstring');var moment=require(_0xf844('0x4'));var db=require(_0xf844('0x5'))['db'];var authService=require(_0xf844('0x6'));var utils=require(_0xf844('0x7'));var client=jayson[_0xf844('0x8')][_0xf844('0x9')]({'port':0x232b});function localAuthenticate(_0x28f13f,_0x474d7d,_0x4dd32d,_0x9ce494){var _0x2b17cf,_0x55e5fd;return db[_0xf844('0xa')][_0xf844('0xb')]({'where':{'id':0x1},'attributes':[_0xf844('0xc'),_0xf844('0xd')],'raw':!![]})[_0xf844('0xe')](function(_0x4e988e){_0x2b17cf=_0x4e988e;return _0x28f13f['findOne']({'attributes':['id',_0xf844('0xf'),_0xf844('0x10'),_0xf844('0x11'),_0xf844('0x12'),_0xf844('0x13'),'blocked','blockedAt',_0xf844('0x14')],'where':{'name':_0x474d7d,'role':{'$or':[_0xf844('0x15'),_0xf844('0x16'),_0xf844('0x17')]}}});})[_0xf844('0xe')](function(_0x3da7cc){if(!_0x3da7cc||_0x3da7cc&&_0x3da7cc[_0xf844('0xf')]!==_0x474d7d){throw new Error(_0xf844('0x18'));}else{_0x55e5fd=_0x3da7cc;return _0x55e5fd;}})['then'](function(){_0x55e5fd[_0xf844('0x19')](_0x4dd32d,function(_0x98feb9,_0x6e9a9){var _0x1c86ff=_0x55e5fd['loginAttempts']+0x1;if(_0x98feb9){return _0x9ce494(_0x98feb9);}else if(!_0x6e9a9){if(_0x55e5fd['disabled']){return _0x9ce494(null,![],{'message':_0xf844('0x18')});}else if(_0x2b17cf[_0xf844('0xc')]>0x0){if(_0x55e5fd['blocked']){if(_0x2b17cf['blockDuration']>0x0){if(moment(_0x55e5fd[_0xf844('0x1a')])[_0xf844('0x1b')](_0x2b17cf[_0xf844('0xd')],_0xf844('0x1c'))>moment()){return _0x9ce494(null,![],{'message':_0xf844('0x18')});}else{return utils[_0xf844('0x1d')](_0x55e5fd,_0x1c86ff,![],null)[_0xf844('0xe')](function(){return _0x9ce494(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}}else{return _0x9ce494(null,![],{'message':_0xf844('0x18')});}}else{if(_0x1c86ff>=_0x2b17cf['allowedLoginAttempts']){return utils[_0xf844('0x1d')](_0x55e5fd,0x0,!![],moment())['then'](function(){return _0x9ce494(null,![],{'message':_0xf844('0x18')});});}else{return utils['clearBlockUser'](_0x55e5fd,_0x1c86ff,![],null)[_0xf844('0xe')](function(){return _0x9ce494(null,![],{'message':_0xf844('0x18')});});}}}else{return _0x9ce494(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{if(_0x55e5fd['disabled']){return _0x9ce494(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else if(_0x2b17cf[_0xf844('0xc')]>0x0){if(_0x55e5fd[_0xf844('0x1e')]){if(_0x2b17cf[_0xf844('0xd')]>0x0){if(moment(_0x55e5fd[_0xf844('0x1a')])[_0xf844('0x1b')](_0x2b17cf[_0xf844('0xd')],_0xf844('0x1c'))>moment()){return _0x9ce494(null,![],{'message':_0xf844('0x18')});}else{return utils[_0xf844('0x1d')](_0x55e5fd,0x0,![],null)[_0xf844('0xe')](function(){return utils[_0xf844('0x1f')](_0x55e5fd);})['then'](function(){return _0x9ce494(null,_0x55e5fd);});}}else{return _0x9ce494(null,![],{'message':_0xf844('0x18')});}}else{return utils['clearBlockUser'](_0x55e5fd,0x0,![],null)[_0xf844('0xe')](function(){return utils[_0xf844('0x1f')](_0x55e5fd);})['then'](function(){return _0x9ce494(null,_0x55e5fd);})[_0xf844('0x20')](function(_0x48291e){return _0x9ce494(null,![],_0x48291e);});}}else{if(_0x55e5fd['blocked']){return _0x9ce494(null,![],{'message':_0xf844('0x18')});}else{return utils['getLicense'](_0x55e5fd)[_0xf844('0xe')](function(){return _0x9ce494(null,_0x55e5fd);});}}}});})[_0xf844('0x20')](function(_0x4ea18f){return _0x9ce494(null,![],_0x4ea18f);});}function sendServiceMail(_0x13fa17){return db[_0xf844('0x21')][_0xf844('0x22')]({'where':{'service':!![]},'attributes':['id',_0xf844('0xf'),_0xf844('0x23')],'include':[{'model':db['MailServerOut'],'as':_0xf844('0x24'),'include':[{'model':db[_0xf844('0x25')],'as':'CloudProvider'}]}]})[_0xf844('0xe')](function(_0x181500){if(!_0x181500){throw new Error(_0xf844('0x26'));}var _0x13e6ba=_0x181500['getSmtpOptions']();var _0x5795e2={'account':_0x13e6ba,'message':_[_0xf844('0x27')]({'from':util[_0xf844('0x28')](_0xf844('0x29'),_0x181500[_0xf844('0xf')],_0x181500[_0xf844('0x23')]||_0x181500[_0xf844('0x24')][_0xf844('0x16')])},_0x13fa17)};return client[_0xf844('0x2a')]('SendMail',_0x5795e2);})[_0xf844('0xe')](function(_0x55846e){if(_0x55846e[_0xf844('0x2b')]){throw new Error(util[_0xf844('0x28')]('SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!',_0x55846e[_0xf844('0x2b')][_0xf844('0x2c')]||JSON[_0xf844('0x2d')](_0x55846e[_0xf844('0x2b')])));}return!![];});}function handleError(_0x1b8775,_0x5e56ec,_0x47320d){return _0x1b8775['status'](_0x5e56ec||0x1f4)[_0xf844('0x2e')]({'message':_0x47320d?_0x47320d['message']||_0x47320d:''});}exports[_0xf844('0x2f')]=function(_0x147fec,_0x28aeff,_0x380b2b){passport[_0xf844('0x19')]('local-login',function(_0x53b6a6,_0x16b1e1,_0x359285){var _0x572a0a=_0x53b6a6||_0x359285;if(_0x572a0a){return handleError(_0x28aeff,0x191,_0x572a0a);}if(!_0x16b1e1){return handleError(_0x28aeff,0x194,{'message':'Something\x20went\x20wrong,\x20please\x20try\x20again.'});}else{var _0x103ba2={'payload':{'id':_0x16b1e1['id'],'role':_0x16b1e1[_0xf844('0x12')]},'options':{'expiresIn':0x15180}};return authService[_0xf844('0x30')](_0x103ba2)[_0xf844('0xe')](function(_0x2ca7e1){_0x28aeff[_0xf844('0x31')]({'id':_0x16b1e1['id'],'token':_0x2ca7e1,'statusCall':'','isAlreadyLogged':_0x16b1e1[_0xf844('0x32')]});});}})(_0x147fec,_0x28aeff,_0x380b2b);};exports[_0xf844('0x33')]=function(_0xc3bd99,_0x18e8ee){if(!_0xc3bd99[_0xf844('0x34')][_0xf844('0x23')]){return handleError(_0x18e8ee,0x1f4,{'message':_0xf844('0x35')});}var _0x54f142=rs['generate']();_0xc3bd99[_0xf844('0x34')][_0xf844('0x23')]=_0xc3bd99[_0xf844('0x34')]['email'][_0xf844('0x36')]()[_0xf844('0x37')]();var _0x4ad885;return db[_0xf844('0xa')][_0xf844('0xb')]({'where':{'id':0x1},'attributes':['allowedLoginAttempts',_0xf844('0xd')],'raw':!![]})[_0xf844('0xe')](function(_0x117060){_0x4ad885=_0x117060;return db[_0xf844('0x38')][_0xf844('0x22')]({'where':{'email':_0xc3bd99['body'][_0xf844('0x23')]}});})['then'](function(_0x3802df){if(!_0x3802df){throw new Error('This\x20email\x20is\x20not\x20registered.');}if(_0x3802df[_0xf844('0x13')]){throw new Error(_0xf844('0x39'));}if(_0x3802df['blocked']){if(moment(_0x3802df[_0xf844('0x1a')])[_0xf844('0x1b')](_0x4ad885[_0xf844('0xd')],_0xf844('0x1c'))>moment()){throw new Error('The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.');}else{_0x3802df['blocked']=![];_0x3802df[_0xf844('0x1a')]=null;}}_0x3802df[_0xf844('0x3a')]=_0x54f142;_0x3802df[_0xf844('0x3b')]=Date[_0xf844('0x3c')]()+0x36ee80;return _0x3802df[_0xf844('0x3d')]();})['then'](function(){return sendServiceMail({'to':_0xc3bd99[_0xf844('0x34')][_0xf844('0x23')],'subject':'xCally\x20Motion\x20Password\x20Reset','text':'You\x20are\x20receiving\x20this\x20because\x20you\x20(or\x20someone\x20else)\x20have\x20requested\x20the\x20reset\x20of\x20the\x20password\x20for\x20your\x20account.\x0a\x0a'+_0xf844('0x3e')+'https://'+_0xc3bd99[_0xf844('0x3f')]['host']+_0xf844('0x40')+_0x54f142+'\x0a\x0a'+_0xf844('0x41')});})[_0xf844('0xe')](function(){_0x18e8ee[_0xf844('0x42')](0xc8)[_0xf844('0x2e')]({'message':'Reset\x20Email\x20sent!'});})[_0xf844('0x20')](function(_0x34d05d){return handleError(_0x18e8ee,0x1f4,_0x34d05d);});};exports['reset']=function(_0x3d1d7b,_0x3324cf){return db[_0xf844('0x38')][_0xf844('0x22')]({'where':{'resetPasswordToken':_0x3d1d7b['params'][_0xf844('0x43')],'resetPasswordExpires':{'$gt':Date[_0xf844('0x3c')]()}}})['then'](function(_0x918254){if(!_0x918254){throw new Error('Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.');}return db[_0xf844('0xa')][_0xf844('0xb')]({'attributes':['id','securePassword',_0xf844('0x44'),'passwordHistoryLimit']})[_0xf844('0xe')](function(_0x47470b){if(_0x47470b[_0xf844('0x45')])authService['validatePasswordPattern'](_0x3d1d7b['body'][_0xf844('0x10')]);if(!_0x47470b['enforcePasswordHistory']||!_0x918254[_0xf844('0x46')])return _0x918254;authService[_0xf844('0x47')](_0x3d1d7b[_0xf844('0x34')][_0xf844('0x10')],_0x918254['previousPasswords'],_0x47470b[_0xf844('0x48')]);return _0x918254;})[_0xf844('0xe')](function(){_0x918254[_0xf844('0x10')]=_0x3d1d7b[_0xf844('0x34')][_0xf844('0x10')];_0x918254[_0xf844('0x3a')]=null;_0x918254[_0xf844('0x3b')]=null;return _0x918254[_0xf844('0x3d')]();});})[_0xf844('0xe')](function(){_0x3324cf[_0xf844('0x42')](0xc8)['send']({'message':'Password\x20reset!'});})[_0xf844('0x20')](function(_0x23d075){return handleError(_0x3324cf,0x1f4,_0x23d075);});};passport[_0xf844('0x49')]('local-login',new LocalStrategy({'usernameField':'name','passwordField':_0xf844('0x10')},function(_0x151588,_0x7c87b2,_0x58fcfc){return localAuthenticate(db[_0xf844('0x38')],_0x151588,_0x7c87b2,_0x58fcfc);}));
\ No newline at end of file