Built motion from commit fade34fd.|2.5.41
[motion2.git] / server / api / authLocal / authLocal.controller.js
index 25ebf16..f3d87db 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb9c5=['email','Smtp','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','service','host','port','secure','auth','user','format','\x22%s\x22\x20<%s>','request','SendMail','error','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','stringify','status','send','message','login','local-login','Something\x20went\x20wrong,\x20please\x20try\x20again.','signToken','json','online','forgot','body','Email\x20parameter\x20is\x20missing','generate','trim','This\x20email\x20is\x20not\x20registered.','The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.','The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.','resetPasswordToken','resetPasswordExpires','now','xCally\x20Motion\x20Password\x20Reset','You\x20are\x20receiving\x20this\x20because\x20you\x20(or\x20someone\x20else)\x20have\x20requested\x20the\x20reset\x20of\x20the\x20password\x20for\x20your\x20account.\x0a\x0a','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','Reset\x20Email\x20sent!','reset','User','params','token','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','securePassword','enforcePasswordHistory','passwordHistoryLimit','password','previousPasswords','validatePasswordHistory','save','passport','Strategy','jayson/promise','lodash','randomstring','moment','../../mysqldb','../../components/auth/service','../../config/utils','client','http','Setting','findOne','allowedLoginAttempts','blockDuration','then','name','salt','role','blocked','blockedAt','loginAttempts','admin','agent','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','authenticate','clearBlockUser','disabled','add','minutes','getLicense','catch','MailAccount','find'];(function(_0x15035b,_0x3eba0a){var _0x2cc7b1=function(_0x144b32){while(--_0x144b32){_0x15035b['push'](_0x15035b['shift']());}};_0x2cc7b1(++_0x3eba0a);}(_0xb9c5,0x90));var _0x5b9c=function(_0x49b640,_0x18b09){_0x49b640=_0x49b640-0x0;var _0xe1ed5=_0xb9c5[_0x49b640];return _0xe1ed5;};'use strict';var util=require('util');var passport=require(_0x5b9c('0x0'));var LocalStrategy=require('passport-local')[_0x5b9c('0x1')];var jayson=require(_0x5b9c('0x2'));var _=require(_0x5b9c('0x3'));var rs=require(_0x5b9c('0x4'));var moment=require(_0x5b9c('0x5'));var db=require(_0x5b9c('0x6'))['db'];var authService=require(_0x5b9c('0x7'));var utils=require(_0x5b9c('0x8'));var client=jayson[_0x5b9c('0x9')][_0x5b9c('0xa')]({'port':0x232b});function localAuthenticate(_0x1d95c1,_0x1aeadf,_0x4ef2f4,_0x3a12c7){var _0x202aaa,_0x3a5b40;return db[_0x5b9c('0xb')][_0x5b9c('0xc')]({'where':{'id':0x1},'attributes':[_0x5b9c('0xd'),_0x5b9c('0xe')],'raw':!![]})[_0x5b9c('0xf')](function(_0x8a6c0d){_0x202aaa=_0x8a6c0d;return _0x1d95c1[_0x5b9c('0xc')]({'attributes':['id',_0x5b9c('0x10'),'password',_0x5b9c('0x11'),_0x5b9c('0x12'),'disabled',_0x5b9c('0x13'),_0x5b9c('0x14'),_0x5b9c('0x15')],'where':{'name':_0x1aeadf,'role':{'$or':[_0x5b9c('0x16'),'user',_0x5b9c('0x17')]}}});})[_0x5b9c('0xf')](function(_0x57c480){if(!_0x57c480||_0x57c480&&_0x57c480[_0x5b9c('0x10')]!==_0x1aeadf){throw new Error(_0x5b9c('0x18'));}else{_0x3a5b40=_0x57c480;return _0x3a5b40;}})[_0x5b9c('0xf')](function(){_0x3a5b40[_0x5b9c('0x19')](_0x4ef2f4,function(_0x2f94a4,_0x1b6422){var _0x42b221=_0x3a5b40['loginAttempts']+0x1;if(_0x2f94a4){return _0x3a12c7(_0x2f94a4);}else if(!_0x1b6422){if(_0x3a5b40['disabled']){return _0x3a12c7(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else if(_0x202aaa[_0x5b9c('0xd')]>0x0){if(_0x3a5b40[_0x5b9c('0x13')]){if(_0x202aaa[_0x5b9c('0xe')]>0x0){if(moment(_0x3a5b40[_0x5b9c('0x14')])['add'](_0x202aaa[_0x5b9c('0xe')],'minutes')>moment()){return _0x3a12c7(null,![],{'message':_0x5b9c('0x18')});}else{return utils[_0x5b9c('0x1a')](_0x3a5b40,_0x42b221,![],null)[_0x5b9c('0xf')](function(){return _0x3a12c7(null,![],{'message':_0x5b9c('0x18')});});}}else{return _0x3a12c7(null,![],{'message':_0x5b9c('0x18')});}}else{if(_0x42b221>=_0x202aaa[_0x5b9c('0xd')]){return utils[_0x5b9c('0x1a')](_0x3a5b40,0x0,!![],moment())[_0x5b9c('0xf')](function(){return _0x3a12c7(null,![],{'message':_0x5b9c('0x18')});});}else{return utils[_0x5b9c('0x1a')](_0x3a5b40,_0x42b221,![],null)[_0x5b9c('0xf')](function(){return _0x3a12c7(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}}}else{return _0x3a12c7(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{if(_0x3a5b40[_0x5b9c('0x1b')]){return _0x3a12c7(null,![],{'message':_0x5b9c('0x18')});}else if(_0x202aaa[_0x5b9c('0xd')]>0x0){if(_0x3a5b40[_0x5b9c('0x13')]){if(_0x202aaa[_0x5b9c('0xe')]>0x0){if(moment(_0x3a5b40[_0x5b9c('0x14')])[_0x5b9c('0x1c')](_0x202aaa[_0x5b9c('0xe')],_0x5b9c('0x1d'))>moment()){return _0x3a12c7(null,![],{'message':_0x5b9c('0x18')});}else{return utils['clearBlockUser'](_0x3a5b40,0x0,![],null)[_0x5b9c('0xf')](function(){return utils['getLicense'](_0x3a5b40);})[_0x5b9c('0xf')](function(){return _0x3a12c7(null,_0x3a5b40);});}}else{return _0x3a12c7(null,![],{'message':_0x5b9c('0x18')});}}else{return utils[_0x5b9c('0x1a')](_0x3a5b40,0x0,![],null)[_0x5b9c('0xf')](function(){return utils[_0x5b9c('0x1e')](_0x3a5b40);})[_0x5b9c('0xf')](function(){return _0x3a12c7(null,_0x3a5b40);})['catch'](function(_0x2a8cee){return _0x3a12c7(null,![],_0x2a8cee);});}}else{if(_0x3a5b40[_0x5b9c('0x13')]){return _0x3a12c7(null,![],{'message':_0x5b9c('0x18')});}else{return utils[_0x5b9c('0x1e')](_0x3a5b40)['then'](function(){return _0x3a12c7(null,_0x3a5b40);});}}}});})[_0x5b9c('0x1f')](function(_0x5061b6){return _0x3a12c7(null,![],_0x5061b6);});}function sendServiceMail(_0x4d99b3){return db[_0x5b9c('0x20')][_0x5b9c('0x21')]({'where':{'service':!![]},'attributes':['id',_0x5b9c('0x10'),_0x5b9c('0x22')],'include':[{'model':db['MailServerOut'],'as':_0x5b9c('0x23')}]})['then'](function(_0x1fbda4){if(!_0x1fbda4){throw new Error(_0x5b9c('0x24'));}var _0x3efb4d={'tls':{'rejectUnauthorized':![]}};if(_0x1fbda4[_0x5b9c('0x23')][_0x5b9c('0x25')]){_0x3efb4d['service']=_0x1fbda4[_0x5b9c('0x23')][_0x5b9c('0x25')];}else{_0x3efb4d[_0x5b9c('0x26')]=_0x1fbda4[_0x5b9c('0x23')][_0x5b9c('0x26')];_0x3efb4d[_0x5b9c('0x27')]=_0x1fbda4[_0x5b9c('0x23')][_0x5b9c('0x27')];_0x3efb4d[_0x5b9c('0x28')]=_0x1fbda4[_0x5b9c('0x23')]['secure'];}if(_0x1fbda4[_0x5b9c('0x23')]['authentication']){_0x3efb4d[_0x5b9c('0x29')]={'user':_0x1fbda4[_0x5b9c('0x23')][_0x5b9c('0x2a')],'pass':_0x1fbda4['Smtp']['pass']};}var _0x5abb4f={'account':_0x3efb4d,'message':_['merge']({'from':util[_0x5b9c('0x2b')](_0x5b9c('0x2c'),_0x1fbda4[_0x5b9c('0x10')],_0x1fbda4[_0x5b9c('0x22')]||_0x1fbda4[_0x5b9c('0x23')][_0x5b9c('0x2a')])},_0x4d99b3)};return client[_0x5b9c('0x2d')](_0x5b9c('0x2e'),_0x5abb4f);})[_0x5b9c('0xf')](function(_0x43b17a){if(_0x43b17a[_0x5b9c('0x2f')]){throw new Error(util['format'](_0x5b9c('0x30'),_0x43b17a['error']['message']||JSON[_0x5b9c('0x31')](_0x43b17a[_0x5b9c('0x2f')])));}return!![];});}function handleError(_0x30086d,_0x156ac1,_0x38bded){return _0x30086d[_0x5b9c('0x32')](_0x156ac1||0x1f4)[_0x5b9c('0x33')]({'message':_0x38bded?_0x38bded[_0x5b9c('0x34')]||_0x38bded:''});}exports[_0x5b9c('0x35')]=function(_0x1c4645,_0x3de07f,_0x500595){passport[_0x5b9c('0x19')](_0x5b9c('0x36'),function(_0x302b78,_0x19cbe3,_0x268462){var _0xdec016=_0x302b78||_0x268462;if(_0xdec016){return handleError(_0x3de07f,0x191,_0xdec016);}if(!_0x19cbe3){return handleError(_0x3de07f,0x194,{'message':_0x5b9c('0x37')});}else{var _0x3f309e={'payload':{'id':_0x19cbe3['id'],'role':_0x19cbe3[_0x5b9c('0x12')]},'options':{'expiresIn':0x15180}};return authService[_0x5b9c('0x38')](_0x3f309e)['then'](function(_0x1fbc9f){_0x3de07f[_0x5b9c('0x39')]({'id':_0x19cbe3['id'],'token':_0x1fbc9f,'statusCall':'','isAlreadyLogged':_0x19cbe3[_0x5b9c('0x3a')]});});}})(_0x1c4645,_0x3de07f,_0x500595);};exports[_0x5b9c('0x3b')]=function(_0x184e55,_0x3d73cf,_0x756b29){if(!_0x184e55[_0x5b9c('0x3c')][_0x5b9c('0x22')]){return handleError(_0x3d73cf,0x1f4,{'message':_0x5b9c('0x3d')});}var _0x2e33ac=rs[_0x5b9c('0x3e')]();_0x184e55[_0x5b9c('0x3c')][_0x5b9c('0x22')]=_0x184e55[_0x5b9c('0x3c')][_0x5b9c('0x22')][_0x5b9c('0x3f')]()['toLowerCase']();var _0x326c8d;return db[_0x5b9c('0xb')]['findOne']({'where':{'id':0x1},'attributes':[_0x5b9c('0xd'),_0x5b9c('0xe')],'raw':!![]})[_0x5b9c('0xf')](function(_0x17b3c6){_0x326c8d=_0x17b3c6;return db['User'][_0x5b9c('0x21')]({'where':{'email':_0x184e55['body']['email']}});})['then'](function(_0x15aa6d){if(!_0x15aa6d){throw new Error(_0x5b9c('0x40'));}if(_0x15aa6d[_0x5b9c('0x1b')]){throw new Error(_0x5b9c('0x41'));}if(_0x15aa6d[_0x5b9c('0x13')]){if(moment(_0x15aa6d['blockedAt'])[_0x5b9c('0x1c')](_0x326c8d[_0x5b9c('0xe')],'minutes')>moment()){throw new Error(_0x5b9c('0x42'));}else{_0x15aa6d[_0x5b9c('0x13')]=![];_0x15aa6d[_0x5b9c('0x14')]=null;}}_0x15aa6d[_0x5b9c('0x43')]=_0x2e33ac;_0x15aa6d[_0x5b9c('0x44')]=Date[_0x5b9c('0x45')]()+0x36ee80;return _0x15aa6d['save']();})[_0x5b9c('0xf')](function(){return sendServiceMail({'to':_0x184e55[_0x5b9c('0x3c')][_0x5b9c('0x22')],'subject':_0x5b9c('0x46'),'text':_0x5b9c('0x47')+_0x5b9c('0x48')+'https://'+_0x184e55[_0x5b9c('0x49')][_0x5b9c('0x26')]+_0x5b9c('0x4a')+_0x2e33ac+'\x0a\x0a'+_0x5b9c('0x4b')});})[_0x5b9c('0xf')](function(){_0x3d73cf[_0x5b9c('0x32')](0xc8)[_0x5b9c('0x33')]({'message':_0x5b9c('0x4c')});})['catch'](function(_0x32f913){return handleError(_0x3d73cf,0x1f4,_0x32f913);});};exports[_0x5b9c('0x4d')]=function(_0x47cc3b,_0x36d772,_0x4b23be){return db[_0x5b9c('0x4e')]['find']({'where':{'resetPasswordToken':_0x47cc3b[_0x5b9c('0x4f')][_0x5b9c('0x50')],'resetPasswordExpires':{'$gt':Date[_0x5b9c('0x45')]()}}})[_0x5b9c('0xf')](function(_0x2c2e1a){if(!_0x2c2e1a){throw new Error(_0x5b9c('0x51'));}return db['Setting'][_0x5b9c('0xc')]({'attributes':['id',_0x5b9c('0x52'),_0x5b9c('0x53'),_0x5b9c('0x54')]})[_0x5b9c('0xf')](function(_0x519206){if(_0x519206['securePassword'])authService['validatePasswordPattern'](_0x47cc3b[_0x5b9c('0x3c')][_0x5b9c('0x55')]);if(!_0x519206[_0x5b9c('0x53')]||!_0x2c2e1a[_0x5b9c('0x56')])return _0x2c2e1a;authService[_0x5b9c('0x57')](_0x47cc3b[_0x5b9c('0x3c')][_0x5b9c('0x55')],_0x2c2e1a[_0x5b9c('0x56')],_0x519206['passwordHistoryLimit']);return _0x2c2e1a;})['then'](function(){_0x2c2e1a['password']=_0x47cc3b[_0x5b9c('0x3c')][_0x5b9c('0x55')];_0x2c2e1a[_0x5b9c('0x43')]=null;_0x2c2e1a[_0x5b9c('0x44')]=null;return _0x2c2e1a[_0x5b9c('0x58')]();});})[_0x5b9c('0xf')](function(){_0x36d772[_0x5b9c('0x32')](0xc8)[_0x5b9c('0x33')]({'message':'Password\x20reset!'});})[_0x5b9c('0x1f')](function(_0x17af12){return handleError(_0x36d772,0x1f4,_0x17af12);});};passport['use'](_0x5b9c('0x36'),new LocalStrategy({'usernameField':_0x5b9c('0x10'),'passwordField':_0x5b9c('0x55')},function(_0x51d44e,_0x3b2de8,_0x12c0e8){return localAuthenticate(db[_0x5b9c('0x4e')],_0x51d44e,_0x3b2de8,_0x12c0e8);}));
\ No newline at end of file
+var _0x1058=['merge','request','SendMail','error','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','stringify','send','message','login','local-login','Something\x20went\x20wrong,\x20please\x20try\x20again.','signToken','forgot','Email\x20parameter\x20is\x20missing','body','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','xCally\x20Motion\x20Password\x20Reset','You\x20are\x20receiving\x20this\x20because\x20you\x20(or\x20someone\x20else)\x20have\x20requested\x20the\x20reset\x20of\x20the\x20password\x20for\x20your\x20account.\x0a\x0a','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','status','reset','params','token','now','securePassword','validatePasswordPattern','enforcePasswordHistory','previousPasswords','passwordHistoryLimit','save','use','util','passport-local','Strategy','jayson/promise','lodash','moment','../../mysqldb','../../components/auth/service','../../config/utils','client','Setting','findOne','allowedLoginAttempts','blockDuration','then','name','password','salt','role','disabled','blockedAt','admin','user','agent','authenticate','loginAttempts','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','blocked','minutes','clearBlockUser','add','getLicense','catch','MailAccount','find','email','MailServerOut','Smtp','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','service','host','port','secure','authentication','auth','pass'];(function(_0x452602,_0x12a16c){var _0x5aa7d8=function(_0x1f9c1a){while(--_0x1f9c1a){_0x452602['push'](_0x452602['shift']());}};_0x5aa7d8(++_0x12a16c);}(_0x1058,0xcb));var _0x8105=function(_0x408294,_0x27a1ec){_0x408294=_0x408294-0x0;var _0x2633f5=_0x1058[_0x408294];return _0x2633f5;};'use strict';var util=require(_0x8105('0x0'));var passport=require('passport');var LocalStrategy=require(_0x8105('0x1'))[_0x8105('0x2')];var jayson=require(_0x8105('0x3'));var _=require(_0x8105('0x4'));var rs=require('randomstring');var moment=require(_0x8105('0x5'));var db=require(_0x8105('0x6'))['db'];var authService=require(_0x8105('0x7'));var utils=require(_0x8105('0x8'));var client=jayson[_0x8105('0x9')]['http']({'port':0x232b});function localAuthenticate(_0x4d3d8a,_0x2e8a72,_0x43ee85,_0x538e4a){var _0xe67bc9,_0x21d436;return db[_0x8105('0xa')][_0x8105('0xb')]({'where':{'id':0x1},'attributes':[_0x8105('0xc'),_0x8105('0xd')],'raw':!![]})[_0x8105('0xe')](function(_0x1ae25b){_0xe67bc9=_0x1ae25b;return _0x4d3d8a[_0x8105('0xb')]({'attributes':['id',_0x8105('0xf'),_0x8105('0x10'),_0x8105('0x11'),_0x8105('0x12'),_0x8105('0x13'),'blocked',_0x8105('0x14'),'loginAttempts'],'where':{'name':_0x2e8a72,'role':{'$or':[_0x8105('0x15'),_0x8105('0x16'),_0x8105('0x17')]}}});})['then'](function(_0x119b1f){if(!_0x119b1f||_0x119b1f&&_0x119b1f['name']!==_0x2e8a72){throw new Error('Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.');}else{_0x21d436=_0x119b1f;return _0x21d436;}})['then'](function(){_0x21d436[_0x8105('0x18')](_0x43ee85,function(_0x455edd,_0x510a36){var _0x165ebf=_0x21d436[_0x8105('0x19')]+0x1;if(_0x455edd){return _0x538e4a(_0x455edd);}else if(!_0x510a36){if(_0x21d436[_0x8105('0x13')]){return _0x538e4a(null,![],{'message':_0x8105('0x1a')});}else if(_0xe67bc9[_0x8105('0xc')]>0x0){if(_0x21d436[_0x8105('0x1b')]){if(_0xe67bc9['blockDuration']>0x0){if(moment(_0x21d436[_0x8105('0x14')])['add'](_0xe67bc9['blockDuration'],_0x8105('0x1c'))>moment()){return _0x538e4a(null,![],{'message':_0x8105('0x1a')});}else{return utils[_0x8105('0x1d')](_0x21d436,_0x165ebf,![],null)[_0x8105('0xe')](function(){return _0x538e4a(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}}else{return _0x538e4a(null,![],{'message':_0x8105('0x1a')});}}else{if(_0x165ebf>=_0xe67bc9[_0x8105('0xc')]){return utils[_0x8105('0x1d')](_0x21d436,0x0,!![],moment())[_0x8105('0xe')](function(){return _0x538e4a(null,![],{'message':_0x8105('0x1a')});});}else{return utils[_0x8105('0x1d')](_0x21d436,_0x165ebf,![],null)[_0x8105('0xe')](function(){return _0x538e4a(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}}}else{return _0x538e4a(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{if(_0x21d436['disabled']){return _0x538e4a(null,![],{'message':_0x8105('0x1a')});}else if(_0xe67bc9[_0x8105('0xc')]>0x0){if(_0x21d436['blocked']){if(_0xe67bc9[_0x8105('0xd')]>0x0){if(moment(_0x21d436['blockedAt'])[_0x8105('0x1e')](_0xe67bc9['blockDuration'],_0x8105('0x1c'))>moment()){return _0x538e4a(null,![],{'message':_0x8105('0x1a')});}else{return utils['clearBlockUser'](_0x21d436,0x0,![],null)[_0x8105('0xe')](function(){return utils['getLicense'](_0x21d436);})['then'](function(){return _0x538e4a(null,_0x21d436);});}}else{return _0x538e4a(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{return utils[_0x8105('0x1d')](_0x21d436,0x0,![],null)[_0x8105('0xe')](function(){return utils[_0x8105('0x1f')](_0x21d436);})[_0x8105('0xe')](function(){return _0x538e4a(null,_0x21d436);})[_0x8105('0x20')](function(_0x2865f9){return _0x538e4a(null,![],_0x2865f9);});}}else{if(_0x21d436[_0x8105('0x1b')]){return _0x538e4a(null,![],{'message':_0x8105('0x1a')});}else{return utils[_0x8105('0x1f')](_0x21d436)[_0x8105('0xe')](function(){return _0x538e4a(null,_0x21d436);});}}}});})[_0x8105('0x20')](function(_0x3f96da){return _0x538e4a(null,![],_0x3f96da);});}function sendServiceMail(_0x2bfe2f){return db[_0x8105('0x21')][_0x8105('0x22')]({'where':{'service':!![]},'attributes':['id',_0x8105('0xf'),_0x8105('0x23')],'include':[{'model':db[_0x8105('0x24')],'as':_0x8105('0x25')}]})['then'](function(_0xe56499){if(!_0xe56499){throw new Error(_0x8105('0x26'));}var _0x885274={'tls':{'rejectUnauthorized':![]}};if(_0xe56499['Smtp']['service']){_0x885274['service']=_0xe56499[_0x8105('0x25')][_0x8105('0x27')];}else{_0x885274[_0x8105('0x28')]=_0xe56499[_0x8105('0x25')][_0x8105('0x28')];_0x885274[_0x8105('0x29')]=_0xe56499[_0x8105('0x25')][_0x8105('0x29')];_0x885274[_0x8105('0x2a')]=_0xe56499[_0x8105('0x25')][_0x8105('0x2a')];}if(_0xe56499[_0x8105('0x25')][_0x8105('0x2b')]){_0x885274[_0x8105('0x2c')]={'user':_0xe56499[_0x8105('0x25')]['user'],'pass':_0xe56499[_0x8105('0x25')][_0x8105('0x2d')]};}var _0x388cfa={'account':_0x885274,'message':_[_0x8105('0x2e')]({'from':util['format']('\x22%s\x22\x20<%s>',_0xe56499['name'],_0xe56499[_0x8105('0x23')]||_0xe56499[_0x8105('0x25')][_0x8105('0x16')])},_0x2bfe2f)};return client[_0x8105('0x2f')](_0x8105('0x30'),_0x388cfa);})['then'](function(_0x1c5dad){if(_0x1c5dad[_0x8105('0x31')]){throw new Error(util['format'](_0x8105('0x32'),_0x1c5dad[_0x8105('0x31')]['message']||JSON[_0x8105('0x33')](_0x1c5dad[_0x8105('0x31')])));}return!![];});}function handleError(_0x53e1c7,_0x577fbc,_0x7995a2){return _0x53e1c7['status'](_0x577fbc||0x1f4)[_0x8105('0x34')]({'message':_0x7995a2?_0x7995a2[_0x8105('0x35')]||_0x7995a2:''});}exports[_0x8105('0x36')]=function(_0x433ef3,_0x953693,_0x1c47db){passport[_0x8105('0x18')](_0x8105('0x37'),function(_0x1c4545,_0x30fdf9,_0xb937ec){var _0xfd476=_0x1c4545||_0xb937ec;if(_0xfd476){return handleError(_0x953693,0x191,_0xfd476);}if(!_0x30fdf9){return handleError(_0x953693,0x194,{'message':_0x8105('0x38')});}else{var _0x56fabd={'payload':{'id':_0x30fdf9['id'],'role':_0x30fdf9[_0x8105('0x12')]},'options':{'expiresIn':0x15180}};return authService[_0x8105('0x39')](_0x56fabd)[_0x8105('0xe')](function(_0x5e8e07){_0x953693['json']({'id':_0x30fdf9['id'],'token':_0x5e8e07,'statusCall':'','isAlreadyLogged':_0x30fdf9['online']});});}})(_0x433ef3,_0x953693,_0x1c47db);};exports[_0x8105('0x3a')]=function(_0x38b093,_0x8c916b,_0x2091d6){if(!_0x38b093['body'][_0x8105('0x23')]){return handleError(_0x8c916b,0x1f4,{'message':_0x8105('0x3b')});}var _0x5a4e63=rs['generate']();_0x38b093[_0x8105('0x3c')][_0x8105('0x23')]=_0x38b093[_0x8105('0x3c')][_0x8105('0x23')][_0x8105('0x3d')]()[_0x8105('0x3e')]();var _0x2821b9;return db['Setting'][_0x8105('0xb')]({'where':{'id':0x1},'attributes':[_0x8105('0xc'),_0x8105('0xd')],'raw':!![]})['then'](function(_0x44ca13){_0x2821b9=_0x44ca13;return db['User']['find']({'where':{'email':_0x38b093[_0x8105('0x3c')][_0x8105('0x23')]}});})['then'](function(_0x57a25a){if(!_0x57a25a){throw new Error(_0x8105('0x3f'));}if(_0x57a25a[_0x8105('0x13')]){throw new Error(_0x8105('0x40'));}if(_0x57a25a[_0x8105('0x1b')]){if(moment(_0x57a25a[_0x8105('0x14')])[_0x8105('0x1e')](_0x2821b9[_0x8105('0xd')],_0x8105('0x1c'))>moment()){throw new Error(_0x8105('0x41'));}else{_0x57a25a[_0x8105('0x1b')]=![];_0x57a25a['blockedAt']=null;}}_0x57a25a[_0x8105('0x42')]=_0x5a4e63;_0x57a25a[_0x8105('0x43')]=Date['now']()+0x36ee80;return _0x57a25a['save']();})[_0x8105('0xe')](function(){return sendServiceMail({'to':_0x38b093[_0x8105('0x3c')][_0x8105('0x23')],'subject':_0x8105('0x44'),'text':_0x8105('0x45')+'Please\x20click\x20on\x20the\x20following\x20link,\x20or\x20paste\x20this\x20into\x20your\x20browser\x20to\x20complete\x20the\x20process:\x0a\x0a'+'https://'+_0x38b093['headers'][_0x8105('0x28')]+'/reset/'+_0x5a4e63+'\x0a\x0a'+_0x8105('0x46')});})[_0x8105('0xe')](function(){_0x8c916b[_0x8105('0x47')](0xc8)[_0x8105('0x34')]({'message':'Reset\x20Email\x20sent!'});})['catch'](function(_0x2b2434){return handleError(_0x8c916b,0x1f4,_0x2b2434);});};exports[_0x8105('0x48')]=function(_0x142b59,_0x314c96,_0x2b0cd8){return db['User']['find']({'where':{'resetPasswordToken':_0x142b59[_0x8105('0x49')][_0x8105('0x4a')],'resetPasswordExpires':{'$gt':Date[_0x8105('0x4b')]()}}})[_0x8105('0xe')](function(_0x68147b){if(!_0x68147b){throw new Error('Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.');}return db[_0x8105('0xa')][_0x8105('0xb')]({'attributes':['id',_0x8105('0x4c'),'enforcePasswordHistory','passwordHistoryLimit']})[_0x8105('0xe')](function(_0x10195e){if(_0x10195e['securePassword'])authService[_0x8105('0x4d')](_0x142b59[_0x8105('0x3c')][_0x8105('0x10')]);if(!_0x10195e[_0x8105('0x4e')]||!_0x68147b[_0x8105('0x4f')])return _0x68147b;authService['validatePasswordHistory'](_0x142b59[_0x8105('0x3c')]['password'],_0x68147b[_0x8105('0x4f')],_0x10195e[_0x8105('0x50')]);return _0x68147b;})[_0x8105('0xe')](function(){_0x68147b['password']=_0x142b59[_0x8105('0x3c')]['password'];_0x68147b['resetPasswordToken']=null;_0x68147b['resetPasswordExpires']=null;return _0x68147b[_0x8105('0x51')]();});})['then'](function(){_0x314c96[_0x8105('0x47')](0xc8)['send']({'message':'Password\x20reset!'});})[_0x8105('0x20')](function(_0x1b294b){return handleError(_0x314c96,0x1f4,_0x1b294b);});};passport[_0x8105('0x52')](_0x8105('0x37'),new LocalStrategy({'usernameField':_0x8105('0xf'),'passwordField':_0x8105('0x10')},function(_0x13116c,_0x5bbbb3,_0x1df269){return localAuthenticate(db['User'],_0x13116c,_0x5bbbb3,_0x1df269);}));
\ No newline at end of file