Built motion from commit (unavailable).|2.5.0
[motion2.git] / server / api / authLocal / authLocal.controller.js
index 6e3db09..4eea7d4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2635=['../../mysqldb','../../components/auth/service','../../config/utils','client','http','Setting','allowedLoginAttempts','blockDuration','then','name','password','salt','role','disabled','blocked','loginAttempts','user','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','authenticate','blockedAt','add','minutes','clearBlockUser','getLicense','catch','MailAccount','find','email','Smtp','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','service','host','port','secure','authentication','auth','pass','merge','\x22%s\x22\x20<%s>','request','SendMail','error','format','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','message','status','send','test','login','local','Something\x20went\x20wrong,\x20please\x20try\x20again.','json','forgot','body','Email\x20parameter\x20is\x20missing','generate','trim','toLowerCase','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','http://','headers','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','Reset\x20Email\x20sent!','reset','User','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','findOne','securePassword','Password\x20reset!','use','util','passport','passport-local','Strategy','jayson/promise','lodash','randomstring','moment'];(function(_0x5f3f88,_0x562baf){var _0xd08119=function(_0x42dbf7){while(--_0x42dbf7){_0x5f3f88['push'](_0x5f3f88['shift']());}};_0xd08119(++_0x562baf);}(_0x2635,0x148));var _0x5263=function(_0x1bb88,_0x2512bc){_0x1bb88=_0x1bb88-0x0;var _0x260c20=_0x2635[_0x1bb88];return _0x260c20;};'use strict';var util=require(_0x5263('0x0'));var passport=require(_0x5263('0x1'));var LocalStrategy=require(_0x5263('0x2'))[_0x5263('0x3')];var jayson=require(_0x5263('0x4'));var _=require(_0x5263('0x5'));var rs=require(_0x5263('0x6'));var moment=require(_0x5263('0x7'));var db=require(_0x5263('0x8'))['db'];var authService=require(_0x5263('0x9'));var utils=require(_0x5263('0xa'));var client=jayson[_0x5263('0xb')][_0x5263('0xc')]({'port':0x232b});function localAuthenticate(_0x2edd24,_0x789367,_0x2870b1,_0x223325){var _0x264c23,_0x3335db;return db[_0x5263('0xd')]['findOne']({'where':{'id':0x1},'attributes':[_0x5263('0xe'),_0x5263('0xf')],'raw':!![]})[_0x5263('0x10')](function(_0x353b84){_0x264c23=_0x353b84;return _0x2edd24['findOne']({'attributes':['id',_0x5263('0x11'),_0x5263('0x12'),_0x5263('0x13'),_0x5263('0x14'),_0x5263('0x15'),_0x5263('0x16'),'blockedAt',_0x5263('0x17')],'where':{'name':_0x789367,'role':{'$or':['admin',_0x5263('0x18'),'agent']}}});})['then'](function(_0x5df9bc){if(!_0x5df9bc||_0x5df9bc&&_0x5df9bc[_0x5263('0x11')]!==_0x789367){throw new Error(_0x5263('0x19'));}else{_0x3335db=_0x5df9bc;return _0x3335db;}})[_0x5263('0x10')](function(){_0x3335db[_0x5263('0x1a')](_0x2870b1,function(_0x1090f8,_0x3f2e33){var _0x15d7aa=_0x3335db[_0x5263('0x17')]+0x1;if(_0x1090f8){return _0x223325(_0x1090f8);}else if(!_0x3f2e33){if(_0x3335db[_0x5263('0x15')]){return _0x223325(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else if(_0x264c23['allowedLoginAttempts']>0x0){if(_0x3335db[_0x5263('0x16')]){if(_0x264c23[_0x5263('0xf')]>0x0){if(moment(_0x3335db[_0x5263('0x1b')])[_0x5263('0x1c')](_0x264c23[_0x5263('0xf')],_0x5263('0x1d'))>moment()){return _0x223325(null,![],{'message':_0x5263('0x19')});}else{return utils['clearBlockUser'](_0x3335db,_0x15d7aa,![],null)[_0x5263('0x10')](function(){return _0x223325(null,![],{'message':_0x5263('0x19')});});}}else{return _0x223325(null,![],{'message':_0x5263('0x19')});}}else{if(_0x15d7aa>=_0x264c23[_0x5263('0xe')]){return utils[_0x5263('0x1e')](_0x3335db,0x0,!![],moment())['then'](function(){return _0x223325(null,![],{'message':_0x5263('0x19')});});}else{return utils[_0x5263('0x1e')](_0x3335db,_0x15d7aa,![],null)['then'](function(){return _0x223325(null,![],{'message':_0x5263('0x19')});});}}}else{return _0x223325(null,![],{'message':_0x5263('0x19')});}}else{if(_0x3335db['disabled']){return _0x223325(null,![],{'message':_0x5263('0x19')});}else if(_0x264c23['allowedLoginAttempts']>0x0){if(_0x3335db[_0x5263('0x16')]){if(_0x264c23[_0x5263('0xf')]>0x0){if(moment(_0x3335db['blockedAt'])[_0x5263('0x1c')](_0x264c23[_0x5263('0xf')],'minutes')>moment()){return _0x223325(null,![],{'message':_0x5263('0x19')});}else{return utils[_0x5263('0x1e')](_0x3335db,0x0,![],null)[_0x5263('0x10')](function(){return utils[_0x5263('0x1f')](_0x3335db);})['then'](function(){return _0x223325(null,_0x3335db);});}}else{return _0x223325(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{return utils[_0x5263('0x1e')](_0x3335db,0x0,![],null)[_0x5263('0x10')](function(){return utils['getLicense'](_0x3335db);})[_0x5263('0x10')](function(){return _0x223325(null,_0x3335db);})['catch'](function(_0x48aaf0){return _0x223325(null,![],_0x48aaf0);});}}else{if(_0x3335db['blocked']){return _0x223325(null,![],{'message':_0x5263('0x19')});}else{return utils[_0x5263('0x1f')](_0x3335db)[_0x5263('0x10')](function(){return _0x223325(null,_0x3335db);});}}}});})[_0x5263('0x20')](function(_0x4fdd9e){return _0x223325(null,![],_0x4fdd9e);});}function sendServiceMail(_0x4bfd22){return db[_0x5263('0x21')][_0x5263('0x22')]({'where':{'service':!![]},'attributes':['id','name',_0x5263('0x23')],'include':[{'model':db['MailServerOut'],'as':_0x5263('0x24')}]})[_0x5263('0x10')](function(_0x1e8322){if(!_0x1e8322){throw new Error(_0x5263('0x25'));}var _0xb4e455={'tls':{'rejectUnauthorized':![]}};if(_0x1e8322['Smtp']['service']){_0xb4e455[_0x5263('0x26')]=_0x1e8322[_0x5263('0x24')]['service'];}else{_0xb4e455[_0x5263('0x27')]=_0x1e8322[_0x5263('0x24')]['host'];_0xb4e455[_0x5263('0x28')]=_0x1e8322[_0x5263('0x24')][_0x5263('0x28')];_0xb4e455[_0x5263('0x29')]=_0x1e8322[_0x5263('0x24')]['secure'];}if(_0x1e8322[_0x5263('0x24')][_0x5263('0x2a')]){_0xb4e455[_0x5263('0x2b')]={'user':_0x1e8322[_0x5263('0x24')][_0x5263('0x18')],'pass':_0x1e8322[_0x5263('0x24')][_0x5263('0x2c')]};}var _0x15460c={'account':_0xb4e455,'message':_[_0x5263('0x2d')]({'from':util['format'](_0x5263('0x2e'),_0x1e8322['name'],_0x1e8322['email']||_0x1e8322[_0x5263('0x24')][_0x5263('0x18')])},_0x4bfd22)};return client[_0x5263('0x2f')](_0x5263('0x30'),_0x15460c);})['then'](function(_0x57a473){if(_0x57a473[_0x5263('0x31')]){throw new Error(util[_0x5263('0x32')](_0x5263('0x33'),_0x57a473['error'][_0x5263('0x34')]||JSON['stringify'](_0x57a473['error'])));}return!![];});}function handleError(_0x552671,_0x4139b1,_0x3599d6){return _0x552671[_0x5263('0x35')](_0x4139b1||0x1f4)[_0x5263('0x36')]({'message':_0x3599d6?_0x3599d6[_0x5263('0x34')]||_0x3599d6:''});}function checkPasswordPattern(_0x203c99,_0x716548,_0x590ab8){if(_0x590ab8){var _0x4f7270=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x4f7270[_0x5263('0x37')](_0x716548)){return _0x203c99;}else{throw new Error('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x203c99;}}exports[_0x5263('0x38')]=function(_0x50d4c5,_0x39dc2f,_0x1bb9a5){passport[_0x5263('0x1a')](_0x5263('0x39'),function(_0x16437e,_0x4b7632,_0x30bb49){var _0x3941f9=_0x16437e||_0x30bb49;if(_0x3941f9){return handleError(_0x39dc2f,0x191,_0x3941f9);}if(!_0x4b7632){return handleError(_0x39dc2f,0x194,{'message':_0x5263('0x3a')});}else{var _0x227022={'payload':{'id':_0x4b7632['id'],'role':_0x4b7632[_0x5263('0x14')]},'options':{'expiresIn':0x15180}};return authService['signToken'](_0x227022)[_0x5263('0x10')](function(_0x5b4b1f){_0x39dc2f[_0x5263('0x3b')]({'id':_0x4b7632['id'],'token':_0x5b4b1f,'statusCall':'','isAlreadyLogged':_0x4b7632['online']});});}})(_0x50d4c5,_0x39dc2f,_0x1bb9a5);};exports[_0x5263('0x3c')]=function(_0x435b1f,_0x483dec,_0x51943a){if(!_0x435b1f[_0x5263('0x3d')][_0x5263('0x23')]){return handleError(_0x483dec,0x1f4,{'message':_0x5263('0x3e')});}var _0x522278=rs[_0x5263('0x3f')]();_0x435b1f[_0x5263('0x3d')][_0x5263('0x23')]=_0x435b1f[_0x5263('0x3d')][_0x5263('0x23')][_0x5263('0x40')]()[_0x5263('0x41')]();var _0x24c7e2;return db[_0x5263('0xd')]['findOne']({'where':{'id':0x1},'attributes':[_0x5263('0xe'),_0x5263('0xf')],'raw':!![]})[_0x5263('0x10')](function(_0x58db13){_0x24c7e2=_0x58db13;return db['User'][_0x5263('0x22')]({'where':{'email':_0x435b1f['body']['email']}});})[_0x5263('0x10')](function(_0x3d8668){if(!_0x3d8668){throw new Error('This\x20email\x20is\x20not\x20registered.');}if(_0x3d8668[_0x5263('0x15')]){throw new Error('The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.');}if(_0x3d8668[_0x5263('0x16')]){if(moment(_0x3d8668[_0x5263('0x1b')])['add'](_0x24c7e2[_0x5263('0xf')],_0x5263('0x1d'))>moment()){throw new Error(_0x5263('0x42'));}else{_0x3d8668[_0x5263('0x16')]=![];_0x3d8668[_0x5263('0x1b')]=null;}}_0x3d8668[_0x5263('0x43')]=_0x522278;_0x3d8668[_0x5263('0x44')]=Date[_0x5263('0x45')]()+0x36ee80;return _0x3d8668[_0x5263('0x46')]();})[_0x5263('0x10')](function(){return sendServiceMail({'to':_0x435b1f[_0x5263('0x3d')][_0x5263('0x23')],'subject':_0x5263('0x47'),'text':'You\x20are\x20receiving\x20this\x20because\x20you\x20(or\x20someone\x20else)\x20have\x20requested\x20the\x20reset\x20of\x20the\x20password\x20for\x20your\x20account.\x0a\x0a'+_0x5263('0x48')+_0x5263('0x49')+_0x435b1f[_0x5263('0x4a')][_0x5263('0x27')]+'/reset/'+_0x522278+'\x0a\x0a'+_0x5263('0x4b')});})['then'](function(){_0x483dec[_0x5263('0x35')](0xc8)['send']({'message':_0x5263('0x4c')});})[_0x5263('0x20')](function(_0x29a44a){return handleError(_0x483dec,0x1f4,_0x29a44a);});};exports[_0x5263('0x4d')]=function(_0xe91acd,_0xbeda73,_0x44078b){var _0x4f716a;return db[_0x5263('0x4e')][_0x5263('0x22')]({'where':{'resetPasswordToken':_0xe91acd['params']['token'],'resetPasswordExpires':{'$gt':Date[_0x5263('0x45')]()}}})[_0x5263('0x10')](function(_0x3a7df4){_0x4f716a=_0x3a7df4;if(!_0x4f716a){throw new Error(_0x5263('0x4f'));}return db['Setting'][_0x5263('0x50')]({'attributes':['id',_0x5263('0x51')]});})[_0x5263('0x10')](function(_0x5ad074){return checkPasswordPattern(_0x5ad074,_0xe91acd['body'][_0x5263('0x12')],_0x5ad074[_0x5263('0x51')]);})['then'](function(){_0x4f716a['password']=_0xe91acd[_0x5263('0x3d')]['password'];_0x4f716a[_0x5263('0x43')]=null;_0x4f716a[_0x5263('0x44')]=null;return _0x4f716a[_0x5263('0x46')]();})['then'](function(){_0xbeda73['status'](0xc8)['send']({'message':_0x5263('0x52')});})[_0x5263('0x20')](function(_0x2f7504){return handleError(_0xbeda73,0x1f4,_0x2f7504);});};passport[_0x5263('0x53')](new LocalStrategy({'usernameField':_0x5263('0x11'),'passwordField':_0x5263('0x12')},function(_0x152e87,_0x7e3aae,_0x32eca8){return localAuthenticate(db[_0x5263('0x4e')],_0x152e87,_0x7e3aae,_0x32eca8);}));
\ No newline at end of file
+var _0x8bf8=['message','stringify','status','test','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','login','local','Something\x20went\x20wrong,\x20please\x20try\x20again.','json','online','forgot','Email\x20parameter\x20is\x20missing','generate','body','trim','toLowerCase','User','This\x20email\x20is\x20not\x20registered.','The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.','The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.','resetPasswordExpires','now','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','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','send','Reset\x20Email\x20sent!','reset','params','token','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','Setting','securePassword','Password\x20reset!','use','util','passport','passport-local','Strategy','jayson/promise','lodash','randomstring','moment','../../mysqldb','../../components/auth/service','../../config/utils','client','findOne','allowedLoginAttempts','blockDuration','name','password','salt','role','blocked','blockedAt','admin','user','agent','then','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','authenticate','loginAttempts','disabled','add','minutes','clearBlockUser','getLicense','catch','find','email','Smtp','service','host','port','secure','authentication','auth','pass','merge','format','\x22%s\x22\x20<%s>','request','SendMail','error'];(function(_0x2283dc,_0x2fcfc5){var _0x16db90=function(_0x376c35){while(--_0x376c35){_0x2283dc['push'](_0x2283dc['shift']());}};_0x16db90(++_0x2fcfc5);}(_0x8bf8,0x126));var _0x88bf=function(_0x598cf7,_0xe52881){_0x598cf7=_0x598cf7-0x0;var _0x4508d2=_0x8bf8[_0x598cf7];return _0x4508d2;};'use strict';var util=require(_0x88bf('0x0'));var passport=require(_0x88bf('0x1'));var LocalStrategy=require(_0x88bf('0x2'))[_0x88bf('0x3')];var jayson=require(_0x88bf('0x4'));var _=require(_0x88bf('0x5'));var rs=require(_0x88bf('0x6'));var moment=require(_0x88bf('0x7'));var db=require(_0x88bf('0x8'))['db'];var authService=require(_0x88bf('0x9'));var utils=require(_0x88bf('0xa'));var client=jayson[_0x88bf('0xb')]['http']({'port':0x232b});function localAuthenticate(_0x454378,_0x1e5fab,_0x32206a,_0x7ff438){var _0x290779,_0x329195;return db['Setting'][_0x88bf('0xc')]({'where':{'id':0x1},'attributes':[_0x88bf('0xd'),_0x88bf('0xe')],'raw':!![]})['then'](function(_0x2137d5){_0x290779=_0x2137d5;return _0x454378[_0x88bf('0xc')]({'attributes':['id',_0x88bf('0xf'),_0x88bf('0x10'),_0x88bf('0x11'),_0x88bf('0x12'),'disabled',_0x88bf('0x13'),_0x88bf('0x14'),'loginAttempts'],'where':{'name':_0x1e5fab,'role':{'$or':[_0x88bf('0x15'),_0x88bf('0x16'),_0x88bf('0x17')]}}});})[_0x88bf('0x18')](function(_0x20abda){if(!_0x20abda||_0x20abda&&_0x20abda['name']!==_0x1e5fab){throw new Error(_0x88bf('0x19'));}else{_0x329195=_0x20abda;return _0x329195;}})[_0x88bf('0x18')](function(){_0x329195[_0x88bf('0x1a')](_0x32206a,function(_0x5e4c31,_0x38b75c){var _0x52f4f1=_0x329195[_0x88bf('0x1b')]+0x1;if(_0x5e4c31){return _0x7ff438(_0x5e4c31);}else if(!_0x38b75c){if(_0x329195[_0x88bf('0x1c')]){return _0x7ff438(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else if(_0x290779[_0x88bf('0xd')]>0x0){if(_0x329195[_0x88bf('0x13')]){if(_0x290779[_0x88bf('0xe')]>0x0){if(moment(_0x329195['blockedAt'])[_0x88bf('0x1d')](_0x290779[_0x88bf('0xe')],_0x88bf('0x1e'))>moment()){return _0x7ff438(null,![],{'message':_0x88bf('0x19')});}else{return utils[_0x88bf('0x1f')](_0x329195,_0x52f4f1,![],null)['then'](function(){return _0x7ff438(null,![],{'message':_0x88bf('0x19')});});}}else{return _0x7ff438(null,![],{'message':_0x88bf('0x19')});}}else{if(_0x52f4f1>=_0x290779[_0x88bf('0xd')]){return utils[_0x88bf('0x1f')](_0x329195,0x0,!![],moment())[_0x88bf('0x18')](function(){return _0x7ff438(null,![],{'message':_0x88bf('0x19')});});}else{return utils[_0x88bf('0x1f')](_0x329195,_0x52f4f1,![],null)[_0x88bf('0x18')](function(){return _0x7ff438(null,![],{'message':_0x88bf('0x19')});});}}}else{return _0x7ff438(null,![],{'message':_0x88bf('0x19')});}}else{if(_0x329195[_0x88bf('0x1c')]){return _0x7ff438(null,![],{'message':_0x88bf('0x19')});}else if(_0x290779[_0x88bf('0xd')]>0x0){if(_0x329195['blocked']){if(_0x290779[_0x88bf('0xe')]>0x0){if(moment(_0x329195[_0x88bf('0x14')])[_0x88bf('0x1d')](_0x290779['blockDuration'],_0x88bf('0x1e'))>moment()){return _0x7ff438(null,![],{'message':_0x88bf('0x19')});}else{return utils[_0x88bf('0x1f')](_0x329195,0x0,![],null)[_0x88bf('0x18')](function(){return utils['getLicense'](_0x329195);})[_0x88bf('0x18')](function(){return _0x7ff438(null,_0x329195);});}}else{return _0x7ff438(null,![],{'message':_0x88bf('0x19')});}}else{return utils[_0x88bf('0x1f')](_0x329195,0x0,![],null)[_0x88bf('0x18')](function(){return utils[_0x88bf('0x20')](_0x329195);})[_0x88bf('0x18')](function(){return _0x7ff438(null,_0x329195);})['catch'](function(_0x800cd3){return _0x7ff438(null,![],_0x800cd3);});}}else{if(_0x329195[_0x88bf('0x13')]){return _0x7ff438(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils[_0x88bf('0x20')](_0x329195)['then'](function(){return _0x7ff438(null,_0x329195);});}}}});})[_0x88bf('0x21')](function(_0x513a28){return _0x7ff438(null,![],_0x513a28);});}function sendServiceMail(_0x22ae86){return db['MailAccount'][_0x88bf('0x22')]({'where':{'service':!![]},'attributes':['id','name',_0x88bf('0x23')],'include':[{'model':db['MailServerOut'],'as':_0x88bf('0x24')}]})[_0x88bf('0x18')](function(_0x5ee6e6){if(!_0x5ee6e6){throw new Error('Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!');}var _0x2622b4={'tls':{'rejectUnauthorized':![]}};if(_0x5ee6e6[_0x88bf('0x24')][_0x88bf('0x25')]){_0x2622b4[_0x88bf('0x25')]=_0x5ee6e6[_0x88bf('0x24')][_0x88bf('0x25')];}else{_0x2622b4[_0x88bf('0x26')]=_0x5ee6e6[_0x88bf('0x24')][_0x88bf('0x26')];_0x2622b4['port']=_0x5ee6e6[_0x88bf('0x24')][_0x88bf('0x27')];_0x2622b4[_0x88bf('0x28')]=_0x5ee6e6['Smtp']['secure'];}if(_0x5ee6e6[_0x88bf('0x24')][_0x88bf('0x29')]){_0x2622b4[_0x88bf('0x2a')]={'user':_0x5ee6e6['Smtp']['user'],'pass':_0x5ee6e6[_0x88bf('0x24')][_0x88bf('0x2b')]};}var _0x1c4cdb={'account':_0x2622b4,'message':_[_0x88bf('0x2c')]({'from':util[_0x88bf('0x2d')](_0x88bf('0x2e'),_0x5ee6e6[_0x88bf('0xf')],_0x5ee6e6[_0x88bf('0x23')]||_0x5ee6e6['Smtp'][_0x88bf('0x16')])},_0x22ae86)};return client[_0x88bf('0x2f')](_0x88bf('0x30'),_0x1c4cdb);})[_0x88bf('0x18')](function(_0x37e291){if(_0x37e291[_0x88bf('0x31')]){throw new Error(util[_0x88bf('0x2d')]('SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!',_0x37e291[_0x88bf('0x31')][_0x88bf('0x32')]||JSON[_0x88bf('0x33')](_0x37e291[_0x88bf('0x31')])));}return!![];});}function handleError(_0x1e8f43,_0x4ee265,_0x49129e){return _0x1e8f43[_0x88bf('0x34')](_0x4ee265||0x1f4)['send']({'message':_0x49129e?_0x49129e[_0x88bf('0x32')]||_0x49129e:''});}function checkPasswordPattern(_0x3c52f6,_0x4eeca8,_0x4c0d8c){if(_0x4c0d8c){var _0x40a245=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x40a245[_0x88bf('0x35')](_0x4eeca8)){return _0x3c52f6;}else{throw new Error(_0x88bf('0x36'));}}else{return _0x3c52f6;}}exports[_0x88bf('0x37')]=function(_0x3e0106,_0x8183c6,_0x2f76f2){passport[_0x88bf('0x1a')](_0x88bf('0x38'),function(_0x3cd466,_0x1a89d1,_0x32f0d5){var _0x226e68=_0x3cd466||_0x32f0d5;if(_0x226e68){return handleError(_0x8183c6,0x191,_0x226e68);}if(!_0x1a89d1){return handleError(_0x8183c6,0x194,{'message':_0x88bf('0x39')});}else{var _0x5dd9d5={'payload':{'id':_0x1a89d1['id'],'role':_0x1a89d1[_0x88bf('0x12')]},'options':{'expiresIn':0x15180}};return authService['signToken'](_0x5dd9d5)[_0x88bf('0x18')](function(_0xf76478){_0x8183c6[_0x88bf('0x3a')]({'id':_0x1a89d1['id'],'token':_0xf76478,'statusCall':'','isAlreadyLogged':_0x1a89d1[_0x88bf('0x3b')]});});}})(_0x3e0106,_0x8183c6,_0x2f76f2);};exports[_0x88bf('0x3c')]=function(_0x501b29,_0x3d0aef,_0x3bf2f8){if(!_0x501b29['body'][_0x88bf('0x23')]){return handleError(_0x3d0aef,0x1f4,{'message':_0x88bf('0x3d')});}var _0x3283c1=rs[_0x88bf('0x3e')]();_0x501b29['body'][_0x88bf('0x23')]=_0x501b29[_0x88bf('0x3f')][_0x88bf('0x23')][_0x88bf('0x40')]()[_0x88bf('0x41')]();var _0x46e548;return db['Setting'][_0x88bf('0xc')]({'where':{'id':0x1},'attributes':[_0x88bf('0xd'),_0x88bf('0xe')],'raw':!![]})['then'](function(_0x6fe146){_0x46e548=_0x6fe146;return db[_0x88bf('0x42')][_0x88bf('0x22')]({'where':{'email':_0x501b29[_0x88bf('0x3f')][_0x88bf('0x23')]}});})[_0x88bf('0x18')](function(_0x2d77bb){if(!_0x2d77bb){throw new Error(_0x88bf('0x43'));}if(_0x2d77bb['disabled']){throw new Error(_0x88bf('0x44'));}if(_0x2d77bb[_0x88bf('0x13')]){if(moment(_0x2d77bb[_0x88bf('0x14')])[_0x88bf('0x1d')](_0x46e548[_0x88bf('0xe')],'minutes')>moment()){throw new Error(_0x88bf('0x45'));}else{_0x2d77bb[_0x88bf('0x13')]=![];_0x2d77bb[_0x88bf('0x14')]=null;}}_0x2d77bb['resetPasswordToken']=_0x3283c1;_0x2d77bb[_0x88bf('0x46')]=Date[_0x88bf('0x47')]()+0x36ee80;return _0x2d77bb['save']();})[_0x88bf('0x18')](function(){return sendServiceMail({'to':_0x501b29['body'][_0x88bf('0x23')],'subject':'xCally\x20Motion\x20Password\x20Reset','text':_0x88bf('0x48')+_0x88bf('0x49')+'http://'+_0x501b29['headers']['host']+_0x88bf('0x4a')+_0x3283c1+'\x0a\x0a'+_0x88bf('0x4b')});})['then'](function(){_0x3d0aef['status'](0xc8)[_0x88bf('0x4c')]({'message':_0x88bf('0x4d')});})[_0x88bf('0x21')](function(_0x237e18){return handleError(_0x3d0aef,0x1f4,_0x237e18);});};exports[_0x88bf('0x4e')]=function(_0x3c9116,_0x38642f,_0x1e8aad){var _0x12be11;return db[_0x88bf('0x42')][_0x88bf('0x22')]({'where':{'resetPasswordToken':_0x3c9116[_0x88bf('0x4f')][_0x88bf('0x50')],'resetPasswordExpires':{'$gt':Date[_0x88bf('0x47')]()}}})['then'](function(_0xa7a27e){_0x12be11=_0xa7a27e;if(!_0x12be11){throw new Error(_0x88bf('0x51'));}return db[_0x88bf('0x52')][_0x88bf('0xc')]({'attributes':['id',_0x88bf('0x53')]});})['then'](function(_0x25f567){return checkPasswordPattern(_0x25f567,_0x3c9116[_0x88bf('0x3f')][_0x88bf('0x10')],_0x25f567[_0x88bf('0x53')]);})[_0x88bf('0x18')](function(){_0x12be11[_0x88bf('0x10')]=_0x3c9116['body']['password'];_0x12be11['resetPasswordToken']=null;_0x12be11[_0x88bf('0x46')]=null;return _0x12be11['save']();})[_0x88bf('0x18')](function(){_0x38642f['status'](0xc8)[_0x88bf('0x4c')]({'message':_0x88bf('0x54')});})[_0x88bf('0x21')](function(_0x5f36e9){return handleError(_0x38642f,0x1f4,_0x5f36e9);});};passport[_0x88bf('0x55')](new LocalStrategy({'usernameField':'name','passwordField':_0x88bf('0x10')},function(_0x4cd9bd,_0x58a0e3,_0x17c2e2){return localAuthenticate(db['User'],_0x4cd9bd,_0x58a0e3,_0x17c2e2);}));
\ No newline at end of file