Built motion from commit 64a6f4bc.|2.6.26
[motion2.git] / server / api / authLocal / authLocal.controller.js
index 09a0c23..5e69d4b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x531f=['moment','../../mysqldb','../../config/utils','client','http','Setting','findOne','blockDuration','then','name','password','role','disabled','blockedAt','loginAttempts','user','agent','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','blocked','add','minutes','allowedLoginAttempts','clearBlockUser','getLicense','catch','MailAccount','find','email','Smtp','CloudProvider','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','merge','request','error','format','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','stringify','status','send','message','login','authenticate','local-login','signToken','json','online','forgot','body','Email\x20parameter\x20is\x20missing','generate','User','This\x20email\x20is\x20not\x20registered.','The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.','resetPasswordToken','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://','host','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','Reset\x20Email\x20sent!','reset','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','securePassword','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','validatePasswordHistory','resetPasswordExpires','Password\x20reset!','use','util','passport-local','Strategy','jayson/promise','randomstring'];(function(_0x4ac358,_0xc014e7){var _0x872e8=function(_0x2d5d8a){while(--_0x2d5d8a){_0x4ac358['push'](_0x4ac358['shift']());}};_0x872e8(++_0xc014e7);}(_0x531f,0x1cf));var _0xf531=function(_0x45050c,_0x2c514e){_0x45050c=_0x45050c-0x0;var _0x43be36=_0x531f[_0x45050c];return _0x43be36;};'use strict';var util=require(_0xf531('0x0'));var passport=require('passport');var LocalStrategy=require(_0xf531('0x1'))[_0xf531('0x2')];var jayson=require(_0xf531('0x3'));var _=require('lodash');var rs=require(_0xf531('0x4'));var moment=require(_0xf531('0x5'));var db=require(_0xf531('0x6'))['db'];var authService=require('../../components/auth/service');var utils=require(_0xf531('0x7'));var client=jayson[_0xf531('0x8')][_0xf531('0x9')]({'port':0x232b});function localAuthenticate(_0x23df96,_0x361ffe,_0x4ca0e3,_0x369339){var _0x15523c,_0x5d0ab3;return db[_0xf531('0xa')][_0xf531('0xb')]({'where':{'id':0x1},'attributes':['allowedLoginAttempts',_0xf531('0xc')],'raw':!![]})[_0xf531('0xd')](function(_0x5cec98){_0x15523c=_0x5cec98;return _0x23df96[_0xf531('0xb')]({'attributes':['id',_0xf531('0xe'),_0xf531('0xf'),'salt',_0xf531('0x10'),_0xf531('0x11'),'blocked',_0xf531('0x12'),_0xf531('0x13')],'where':{'name':_0x361ffe,'role':{'$or':['admin',_0xf531('0x14'),_0xf531('0x15')]}}});})[_0xf531('0xd')](function(_0x54b678){if(!_0x54b678||_0x54b678&&_0x54b678[_0xf531('0xe')]!==_0x361ffe){throw new Error(_0xf531('0x16'));}else{_0x5d0ab3=_0x54b678;return _0x5d0ab3;}})['then'](function(){_0x5d0ab3['authenticate'](_0x4ca0e3,function(_0x501d49,_0x1e4232){var _0x1737b8=_0x5d0ab3[_0xf531('0x13')]+0x1;if(_0x501d49){return _0x369339(_0x501d49);}else if(!_0x1e4232){if(_0x5d0ab3[_0xf531('0x11')]){return _0x369339(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else if(_0x15523c['allowedLoginAttempts']>0x0){if(_0x5d0ab3[_0xf531('0x17')]){if(_0x15523c[_0xf531('0xc')]>0x0){if(moment(_0x5d0ab3[_0xf531('0x12')])[_0xf531('0x18')](_0x15523c[_0xf531('0xc')],_0xf531('0x19'))>moment()){return _0x369339(null,![],{'message':_0xf531('0x16')});}else{return utils['clearBlockUser'](_0x5d0ab3,_0x1737b8,![],null)[_0xf531('0xd')](function(){return _0x369339(null,![],{'message':_0xf531('0x16')});});}}else{return _0x369339(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{if(_0x1737b8>=_0x15523c[_0xf531('0x1a')]){return utils[_0xf531('0x1b')](_0x5d0ab3,0x0,!![],moment())[_0xf531('0xd')](function(){return _0x369339(null,![],{'message':_0xf531('0x16')});});}else{return utils[_0xf531('0x1b')](_0x5d0ab3,_0x1737b8,![],null)[_0xf531('0xd')](function(){return _0x369339(null,![],{'message':_0xf531('0x16')});});}}}else{return _0x369339(null,![],{'message':_0xf531('0x16')});}}else{if(_0x5d0ab3[_0xf531('0x11')]){return _0x369339(null,![],{'message':_0xf531('0x16')});}else if(_0x15523c['allowedLoginAttempts']>0x0){if(_0x5d0ab3['blocked']){if(_0x15523c[_0xf531('0xc')]>0x0){if(moment(_0x5d0ab3[_0xf531('0x12')])[_0xf531('0x18')](_0x15523c[_0xf531('0xc')],_0xf531('0x19'))>moment()){return _0x369339(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils[_0xf531('0x1b')](_0x5d0ab3,0x0,![],null)[_0xf531('0xd')](function(){return utils[_0xf531('0x1c')](_0x5d0ab3);})['then'](function(){return _0x369339(null,_0x5d0ab3);});}}else{return _0x369339(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{return utils[_0xf531('0x1b')](_0x5d0ab3,0x0,![],null)['then'](function(){return utils['getLicense'](_0x5d0ab3);})[_0xf531('0xd')](function(){return _0x369339(null,_0x5d0ab3);})[_0xf531('0x1d')](function(_0x3b1def){return _0x369339(null,![],_0x3b1def);});}}else{if(_0x5d0ab3[_0xf531('0x17')]){return _0x369339(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils[_0xf531('0x1c')](_0x5d0ab3)[_0xf531('0xd')](function(){return _0x369339(null,_0x5d0ab3);});}}}});})[_0xf531('0x1d')](function(_0x19eb5b){return _0x369339(null,![],_0x19eb5b);});}function sendServiceMail(_0x16ebcd){return db[_0xf531('0x1e')][_0xf531('0x1f')]({'where':{'service':!![]},'attributes':['id',_0xf531('0xe'),_0xf531('0x20')],'include':[{'model':db['MailServerOut'],'as':_0xf531('0x21'),'include':[{'model':db['CloudProvider'],'as':_0xf531('0x22')}]}]})[_0xf531('0xd')](function(_0x196491){if(!_0x196491){throw new Error(_0xf531('0x23'));}var _0x2883e9=_0x196491['getSmtpOptions']();var _0x249264={'account':_0x2883e9,'message':_[_0xf531('0x24')]({'from':util['format']('\x22%s\x22\x20<%s>',_0x196491[_0xf531('0xe')],_0x196491[_0xf531('0x20')]||_0x196491['Smtp']['user'])},_0x16ebcd)};return client[_0xf531('0x25')]('SendMail',_0x249264);})[_0xf531('0xd')](function(_0x1df4fa){if(_0x1df4fa[_0xf531('0x26')]){throw new Error(util[_0xf531('0x27')](_0xf531('0x28'),_0x1df4fa[_0xf531('0x26')]['message']||JSON[_0xf531('0x29')](_0x1df4fa['error'])));}return!![];});}function handleError(_0xba1d9e,_0x2433b0,_0x6acd70){return _0xba1d9e[_0xf531('0x2a')](_0x2433b0||0x1f4)[_0xf531('0x2b')]({'message':_0x6acd70?_0x6acd70[_0xf531('0x2c')]||_0x6acd70:''});}exports[_0xf531('0x2d')]=function(_0x10edc7,_0xfe8635,_0x48adf4){passport[_0xf531('0x2e')](_0xf531('0x2f'),function(_0x14625e,_0x4fce47,_0xe12d2a){var _0xce2968=_0x14625e||_0xe12d2a;if(_0xce2968){return handleError(_0xfe8635,0x191,_0xce2968);}if(!_0x4fce47){return handleError(_0xfe8635,0x194,{'message':'Something\x20went\x20wrong,\x20please\x20try\x20again.'});}else{var _0x27ccc5={'payload':{'id':_0x4fce47['id'],'role':_0x4fce47['role']},'options':{'expiresIn':0x15180}};return authService[_0xf531('0x30')](_0x27ccc5)[_0xf531('0xd')](function(_0x5bcb11){_0xfe8635[_0xf531('0x31')]({'id':_0x4fce47['id'],'token':_0x5bcb11,'statusCall':'','isAlreadyLogged':_0x4fce47[_0xf531('0x32')]});});}})(_0x10edc7,_0xfe8635,_0x48adf4);};exports[_0xf531('0x33')]=function(_0x461042,_0x34107a){if(!_0x461042[_0xf531('0x34')][_0xf531('0x20')]){return handleError(_0x34107a,0x1f4,{'message':_0xf531('0x35')});}var _0x10d9da=rs[_0xf531('0x36')]();_0x461042[_0xf531('0x34')][_0xf531('0x20')]=_0x461042['body'][_0xf531('0x20')]['trim']()['toLowerCase']();var _0x53cb1b;return db[_0xf531('0xa')][_0xf531('0xb')]({'where':{'id':0x1},'attributes':['allowedLoginAttempts',_0xf531('0xc')],'raw':!![]})[_0xf531('0xd')](function(_0x303292){_0x53cb1b=_0x303292;return db[_0xf531('0x37')][_0xf531('0x1f')]({'where':{'email':_0x461042[_0xf531('0x34')][_0xf531('0x20')]}});})[_0xf531('0xd')](function(_0x11557c){if(!_0x11557c){throw new Error(_0xf531('0x38'));}if(_0x11557c['disabled']){throw new Error('The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.');}if(_0x11557c[_0xf531('0x17')]){if(moment(_0x11557c[_0xf531('0x12')])[_0xf531('0x18')](_0x53cb1b[_0xf531('0xc')],'minutes')>moment()){throw new Error(_0xf531('0x39'));}else{_0x11557c[_0xf531('0x17')]=![];_0x11557c[_0xf531('0x12')]=null;}}_0x11557c[_0xf531('0x3a')]=_0x10d9da;_0x11557c['resetPasswordExpires']=Date[_0xf531('0x3b')]()+0x36ee80;return _0x11557c[_0xf531('0x3c')]();})[_0xf531('0xd')](function(){return sendServiceMail({'to':_0x461042[_0xf531('0x34')][_0xf531('0x20')],'subject':_0xf531('0x3d'),'text':'You\x20are\x20receiving\x20this\x20because\x20you\x20(or\x20someone\x20else)\x20have\x20requested\x20the\x20reset\x20of\x20the\x20password\x20for\x20your\x20account.\x0a\x0a'+_0xf531('0x3e')+_0xf531('0x3f')+_0x461042['headers'][_0xf531('0x40')]+_0xf531('0x41')+_0x10d9da+'\x0a\x0a'+_0xf531('0x42')});})[_0xf531('0xd')](function(){_0x34107a[_0xf531('0x2a')](0xc8)['send']({'message':_0xf531('0x43')});})[_0xf531('0x1d')](function(_0x1e28e0){return handleError(_0x34107a,0x1f4,_0x1e28e0);});};exports[_0xf531('0x44')]=function(_0x3ea02a,_0x50249a){return db[_0xf531('0x37')][_0xf531('0x1f')]({'where':{'resetPasswordToken':_0x3ea02a['params']['token'],'resetPasswordExpires':{'$gt':Date[_0xf531('0x3b')]()}}})['then'](function(_0x392999){if(!_0x392999){throw new Error(_0xf531('0x45'));}return db[_0xf531('0xa')]['findOne']({'attributes':['id',_0xf531('0x46'),_0xf531('0x47'),_0xf531('0x48')]})['then'](function(_0x33172c){if(_0x33172c[_0xf531('0x46')])authService[_0xf531('0x49')](_0x3ea02a[_0xf531('0x34')][_0xf531('0xf')]);if(!_0x33172c[_0xf531('0x47')]||!_0x392999['previousPasswords'])return _0x392999;authService[_0xf531('0x4a')](_0x3ea02a[_0xf531('0x34')]['password'],_0x392999['previousPasswords'],_0x33172c['passwordHistoryLimit']);return _0x392999;})[_0xf531('0xd')](function(){_0x392999[_0xf531('0xf')]=_0x3ea02a[_0xf531('0x34')][_0xf531('0xf')];_0x392999['resetPasswordToken']=null;_0x392999[_0xf531('0x4b')]=null;return _0x392999['save']();});})[_0xf531('0xd')](function(){_0x50249a[_0xf531('0x2a')](0xc8)[_0xf531('0x2b')]({'message':_0xf531('0x4c')});})[_0xf531('0x1d')](function(_0x267006){return handleError(_0x50249a,0x1f4,_0x267006);});};passport[_0xf531('0x4d')](_0xf531('0x2f'),new LocalStrategy({'usernameField':_0xf531('0xe'),'passwordField':_0xf531('0xf')},function(_0x2520d2,_0x568c93,_0x2ef290){return localAuthenticate(db[_0xf531('0x37')],_0x2520d2,_0x568c93,_0x2ef290);}));
\ No newline at end of file
+var _0xa6bf=['message','status','Something\x20went\x20wrong,\x20please\x20try\x20again.','signToken','online','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.','resetPasswordExpires','save','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','host','Reset\x20Email\x20sent!','token','now','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','securePassword','enforcePasswordHistory','passwordHistoryLimit','previousPasswords','validatePasswordHistory','resetPasswordToken','local-login','User','util','passport','passport-local','Strategy','jayson/promise','lodash','randomstring','../../components/auth/service','../../config/utils','client','Setting','findOne','allowedLoginAttempts','blockDuration','then','name','password','role','blocked','blockedAt','loginAttempts','admin','agent','authenticate','disabled','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','add','minutes','clearBlockUser','getLicense','catch','MailAccount','find','email','MailServerOut','Smtp','CloudProvider','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','getSmtpOptions','merge','format','\x22%s\x22\x20<%s>','request','SendMail','error'];(function(_0x2f810c,_0x2eea8f){var _0x23148e=function(_0xa88b6f){while(--_0xa88b6f){_0x2f810c['push'](_0x2f810c['shift']());}};_0x23148e(++_0x2eea8f);}(_0xa6bf,0x1ee));var _0xfa6b=function(_0x2c4915,_0x49f1b0){_0x2c4915=_0x2c4915-0x0;var _0xcc391=_0xa6bf[_0x2c4915];return _0xcc391;};'use strict';var util=require(_0xfa6b('0x0'));var passport=require(_0xfa6b('0x1'));var LocalStrategy=require(_0xfa6b('0x2'))[_0xfa6b('0x3')];var jayson=require(_0xfa6b('0x4'));var _=require(_0xfa6b('0x5'));var rs=require(_0xfa6b('0x6'));var moment=require('moment');var db=require('../../mysqldb')['db'];var authService=require(_0xfa6b('0x7'));var utils=require(_0xfa6b('0x8'));var client=jayson[_0xfa6b('0x9')]['http']({'port':0x232b});function localAuthenticate(_0x55230d,_0x2920ee,_0x2bbb1a,_0x314b0d){var _0x51abea,_0x45d75e;return db[_0xfa6b('0xa')][_0xfa6b('0xb')]({'where':{'id':0x1},'attributes':[_0xfa6b('0xc'),_0xfa6b('0xd')],'raw':!![]})[_0xfa6b('0xe')](function(_0x341e69){_0x51abea=_0x341e69;return _0x55230d[_0xfa6b('0xb')]({'attributes':['id',_0xfa6b('0xf'),_0xfa6b('0x10'),'salt',_0xfa6b('0x11'),'disabled',_0xfa6b('0x12'),_0xfa6b('0x13'),_0xfa6b('0x14')],'where':{'name':_0x2920ee,'role':{'$or':[_0xfa6b('0x15'),'user',_0xfa6b('0x16')]}}});})[_0xfa6b('0xe')](function(_0x2b20f5){if(!_0x2b20f5||_0x2b20f5&&_0x2b20f5[_0xfa6b('0xf')]!==_0x2920ee){throw new Error('Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.');}else{_0x45d75e=_0x2b20f5;return _0x45d75e;}})[_0xfa6b('0xe')](function(){_0x45d75e[_0xfa6b('0x17')](_0x2bbb1a,function(_0x132900,_0x39d4fc){var _0x1614d1=_0x45d75e['loginAttempts']+0x1;if(_0x132900){return _0x314b0d(_0x132900);}else if(!_0x39d4fc){if(_0x45d75e[_0xfa6b('0x18')]){return _0x314b0d(null,![],{'message':_0xfa6b('0x19')});}else if(_0x51abea['allowedLoginAttempts']>0x0){if(_0x45d75e[_0xfa6b('0x12')]){if(_0x51abea[_0xfa6b('0xd')]>0x0){if(moment(_0x45d75e[_0xfa6b('0x13')])[_0xfa6b('0x1a')](_0x51abea['blockDuration'],_0xfa6b('0x1b'))>moment()){return _0x314b0d(null,![],{'message':_0xfa6b('0x19')});}else{return utils[_0xfa6b('0x1c')](_0x45d75e,_0x1614d1,![],null)['then'](function(){return _0x314b0d(null,![],{'message':_0xfa6b('0x19')});});}}else{return _0x314b0d(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{if(_0x1614d1>=_0x51abea[_0xfa6b('0xc')]){return utils[_0xfa6b('0x1c')](_0x45d75e,0x0,!![],moment())[_0xfa6b('0xe')](function(){return _0x314b0d(null,![],{'message':_0xfa6b('0x19')});});}else{return utils[_0xfa6b('0x1c')](_0x45d75e,_0x1614d1,![],null)['then'](function(){return _0x314b0d(null,![],{'message':_0xfa6b('0x19')});});}}}else{return _0x314b0d(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{if(_0x45d75e[_0xfa6b('0x18')]){return _0x314b0d(null,![],{'message':_0xfa6b('0x19')});}else if(_0x51abea[_0xfa6b('0xc')]>0x0){if(_0x45d75e[_0xfa6b('0x12')]){if(_0x51abea[_0xfa6b('0xd')]>0x0){if(moment(_0x45d75e['blockedAt'])[_0xfa6b('0x1a')](_0x51abea[_0xfa6b('0xd')],'minutes')>moment()){return _0x314b0d(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils[_0xfa6b('0x1c')](_0x45d75e,0x0,![],null)[_0xfa6b('0xe')](function(){return utils[_0xfa6b('0x1d')](_0x45d75e);})[_0xfa6b('0xe')](function(){return _0x314b0d(null,_0x45d75e);});}}else{return _0x314b0d(null,![],{'message':_0xfa6b('0x19')});}}else{return utils[_0xfa6b('0x1c')](_0x45d75e,0x0,![],null)[_0xfa6b('0xe')](function(){return utils[_0xfa6b('0x1d')](_0x45d75e);})[_0xfa6b('0xe')](function(){return _0x314b0d(null,_0x45d75e);})[_0xfa6b('0x1e')](function(_0x50a354){return _0x314b0d(null,![],_0x50a354);});}}else{if(_0x45d75e[_0xfa6b('0x12')]){return _0x314b0d(null,![],{'message':_0xfa6b('0x19')});}else{return utils[_0xfa6b('0x1d')](_0x45d75e)[_0xfa6b('0xe')](function(){return _0x314b0d(null,_0x45d75e);});}}}});})[_0xfa6b('0x1e')](function(_0x5c75ea){return _0x314b0d(null,![],_0x5c75ea);});}function sendServiceMail(_0x6b443){return db[_0xfa6b('0x1f')][_0xfa6b('0x20')]({'where':{'service':!![]},'attributes':['id','name',_0xfa6b('0x21')],'include':[{'model':db[_0xfa6b('0x22')],'as':_0xfa6b('0x23'),'include':[{'model':db[_0xfa6b('0x24')],'as':'CloudProvider'}]}]})['then'](function(_0x536f38){if(!_0x536f38){throw new Error(_0xfa6b('0x25'));}var _0x19d3ef=_0x536f38[_0xfa6b('0x26')]();var _0x135330={'account':_0x19d3ef,'message':_[_0xfa6b('0x27')]({'from':util[_0xfa6b('0x28')](_0xfa6b('0x29'),_0x536f38['name'],_0x536f38[_0xfa6b('0x21')]||_0x536f38[_0xfa6b('0x23')]['user'])},_0x6b443)};return client[_0xfa6b('0x2a')](_0xfa6b('0x2b'),_0x135330);})[_0xfa6b('0xe')](function(_0x249ac1){if(_0x249ac1[_0xfa6b('0x2c')]){throw new Error(util[_0xfa6b('0x28')]('SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!',_0x249ac1[_0xfa6b('0x2c')][_0xfa6b('0x2d')]||JSON['stringify'](_0x249ac1[_0xfa6b('0x2c')])));}return!![];});}function handleError(_0x19f09d,_0x1f760c,_0x15f5c7){return _0x19f09d[_0xfa6b('0x2e')](_0x1f760c||0x1f4)['send']({'message':_0x15f5c7?_0x15f5c7[_0xfa6b('0x2d')]||_0x15f5c7:''});}exports['login']=function(_0xebcd1,_0x4a1415,_0x78942b){passport[_0xfa6b('0x17')]('local-login',function(_0x4a92fb,_0x52b006,_0x10e4e6){var _0x5d0d7d=_0x4a92fb||_0x10e4e6;if(_0x5d0d7d){return handleError(_0x4a1415,0x191,_0x5d0d7d);}if(!_0x52b006){return handleError(_0x4a1415,0x194,{'message':_0xfa6b('0x2f')});}else{var _0x641689={'payload':{'id':_0x52b006['id'],'role':_0x52b006[_0xfa6b('0x11')]},'options':{'expiresIn':0x15180}};return authService[_0xfa6b('0x30')](_0x641689)[_0xfa6b('0xe')](function(_0x570bd6){_0x4a1415['json']({'id':_0x52b006['id'],'token':_0x570bd6,'statusCall':'','isAlreadyLogged':_0x52b006[_0xfa6b('0x31')]});});}})(_0xebcd1,_0x4a1415,_0x78942b);};exports['forgot']=function(_0x483b2b,_0x5bfa3a){if(!_0x483b2b[_0xfa6b('0x32')][_0xfa6b('0x21')]){return handleError(_0x5bfa3a,0x1f4,{'message':_0xfa6b('0x33')});}var _0xfc2751=rs[_0xfa6b('0x34')]();_0x483b2b['body'][_0xfa6b('0x21')]=_0x483b2b[_0xfa6b('0x32')][_0xfa6b('0x21')][_0xfa6b('0x35')]()[_0xfa6b('0x36')]();var _0x1fe190;return db[_0xfa6b('0xa')]['findOne']({'where':{'id':0x1},'attributes':[_0xfa6b('0xc'),_0xfa6b('0xd')],'raw':!![]})['then'](function(_0x4b89f1){_0x1fe190=_0x4b89f1;return db['User'][_0xfa6b('0x20')]({'where':{'email':_0x483b2b[_0xfa6b('0x32')]['email']}});})[_0xfa6b('0xe')](function(_0x3d76ca){if(!_0x3d76ca){throw new Error(_0xfa6b('0x37'));}if(_0x3d76ca[_0xfa6b('0x18')]){throw new Error(_0xfa6b('0x38'));}if(_0x3d76ca[_0xfa6b('0x12')]){if(moment(_0x3d76ca[_0xfa6b('0x13')])[_0xfa6b('0x1a')](_0x1fe190[_0xfa6b('0xd')],_0xfa6b('0x1b'))>moment()){throw new Error(_0xfa6b('0x39'));}else{_0x3d76ca[_0xfa6b('0x12')]=![];_0x3d76ca[_0xfa6b('0x13')]=null;}}_0x3d76ca['resetPasswordToken']=_0xfc2751;_0x3d76ca[_0xfa6b('0x3a')]=Date['now']()+0x36ee80;return _0x3d76ca[_0xfa6b('0x3b')]();})[_0xfa6b('0xe')](function(){return sendServiceMail({'to':_0x483b2b['body'][_0xfa6b('0x21')],'subject':_0xfa6b('0x3c'),'text':_0xfa6b('0x3d')+_0xfa6b('0x3e')+'https://'+_0x483b2b[_0xfa6b('0x3f')][_0xfa6b('0x40')]+'/reset/'+_0xfc2751+'\x0a\x0a'+'If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a'});})[_0xfa6b('0xe')](function(){_0x5bfa3a[_0xfa6b('0x2e')](0xc8)['send']({'message':_0xfa6b('0x41')});})[_0xfa6b('0x1e')](function(_0x1d0345){return handleError(_0x5bfa3a,0x1f4,_0x1d0345);});};exports['reset']=function(_0x57f206,_0x143213){return db['User'][_0xfa6b('0x20')]({'where':{'resetPasswordToken':_0x57f206['params'][_0xfa6b('0x42')],'resetPasswordExpires':{'$gt':Date[_0xfa6b('0x43')]()}}})['then'](function(_0x5cd874){if(!_0x5cd874){throw new Error(_0xfa6b('0x44'));}return db['Setting'][_0xfa6b('0xb')]({'attributes':['id',_0xfa6b('0x45'),_0xfa6b('0x46'),_0xfa6b('0x47')]})['then'](function(_0x4e7a1e){if(_0x4e7a1e[_0xfa6b('0x45')])authService['validatePasswordPattern'](_0x57f206[_0xfa6b('0x32')][_0xfa6b('0x10')]);if(!_0x4e7a1e['enforcePasswordHistory']||!_0x5cd874[_0xfa6b('0x48')])return _0x5cd874;authService[_0xfa6b('0x49')](_0x57f206[_0xfa6b('0x32')]['password'],_0x5cd874[_0xfa6b('0x48')],_0x4e7a1e['passwordHistoryLimit']);return _0x5cd874;})[_0xfa6b('0xe')](function(){_0x5cd874[_0xfa6b('0x10')]=_0x57f206[_0xfa6b('0x32')]['password'];_0x5cd874[_0xfa6b('0x4a')]=null;_0x5cd874[_0xfa6b('0x3a')]=null;return _0x5cd874[_0xfa6b('0x3b')]();});})[_0xfa6b('0xe')](function(){_0x143213[_0xfa6b('0x2e')](0xc8)['send']({'message':'Password\x20reset!'});})[_0xfa6b('0x1e')](function(_0x1104ad){return handleError(_0x143213,0x1f4,_0x1104ad);});};passport['use'](_0xfa6b('0x4b'),new LocalStrategy({'usernameField':'name','passwordField':_0xfa6b('0x10')},function(_0x25261f,_0x49aa2,_0x715b09){return localAuthenticate(db[_0xfa6b('0x4c')],_0x25261f,_0x49aa2,_0x715b09);}));
\ No newline at end of file