Built motion from commit e8da49ee.|2.6.33
[motion2.git] / server / api / authLocal / authLocal.controller.js
index 0d8e840..70089d3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf5a2=['error','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','message','status','send','login','local-login','signToken','online','forgot','body','Email\x20parameter\x20is\x20missing','generate','trim','toLowerCase','User','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','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','https://','headers','host','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','Reset\x20Email\x20sent!','catch','params','token','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','securePassword','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','password','previousPasswords','validatePasswordHistory','Password\x20reset!','use','util','passport','Strategy','jayson/promise','../../components/auth/service','../../config/utils','client','http','Setting','findOne','allowedLoginAttempts','then','salt','role','disabled','blockedAt','loginAttempts','admin','user','agent','name','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','authenticate','add','blockDuration','clearBlockUser','minutes','getLicense','blocked','MailAccount','find','email','MailServerOut','CloudProvider','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','getSmtpOptions','merge','format','\x22%s\x22\x20<%s>','Smtp','request'];(function(_0xf73dcd,_0x15c363){var _0x44c1e2=function(_0x5f1996){while(--_0x5f1996){_0xf73dcd['push'](_0xf73dcd['shift']());}};_0x44c1e2(++_0x15c363);}(_0xf5a2,0x185));var _0x2f5a=function(_0x480c57,_0x5bba33){_0x480c57=_0x480c57-0x0;var _0x1109b7=_0xf5a2[_0x480c57];return _0x1109b7;};'use strict';var util=require(_0x2f5a('0x0'));var passport=require(_0x2f5a('0x1'));var LocalStrategy=require('passport-local')[_0x2f5a('0x2')];var jayson=require(_0x2f5a('0x3'));var _=require('lodash');var rs=require('randomstring');var moment=require('moment');var db=require('../../mysqldb')['db'];var authService=require(_0x2f5a('0x4'));var utils=require(_0x2f5a('0x5'));var client=jayson[_0x2f5a('0x6')][_0x2f5a('0x7')]({'port':0x232b});function localAuthenticate(_0x5ee553,_0x2cd5f2,_0xbb0bec,_0x1186a6){var _0x4adae1,_0x112fb9;return db[_0x2f5a('0x8')][_0x2f5a('0x9')]({'where':{'id':0x1},'attributes':[_0x2f5a('0xa'),'blockDuration'],'raw':!![]})[_0x2f5a('0xb')](function(_0x173089){_0x4adae1=_0x173089;return _0x5ee553['findOne']({'attributes':['id','name','password',_0x2f5a('0xc'),_0x2f5a('0xd'),_0x2f5a('0xe'),'blocked',_0x2f5a('0xf'),_0x2f5a('0x10')],'where':{'name':_0x2cd5f2,'role':{'$or':[_0x2f5a('0x11'),_0x2f5a('0x12'),_0x2f5a('0x13')]}}});})['then'](function(_0x2d4e15){if(!_0x2d4e15||_0x2d4e15&&_0x2d4e15[_0x2f5a('0x14')]!==_0x2cd5f2){throw new Error(_0x2f5a('0x15'));}else{_0x112fb9=_0x2d4e15;return _0x112fb9;}})[_0x2f5a('0xb')](function(){_0x112fb9[_0x2f5a('0x16')](_0xbb0bec,function(_0x5ca12f,_0x5cbe8b){var _0x3cdc3a=_0x112fb9[_0x2f5a('0x10')]+0x1;if(_0x5ca12f){return _0x1186a6(_0x5ca12f);}else if(!_0x5cbe8b){if(_0x112fb9['disabled']){return _0x1186a6(null,![],{'message':_0x2f5a('0x15')});}else if(_0x4adae1['allowedLoginAttempts']>0x0){if(_0x112fb9['blocked']){if(_0x4adae1['blockDuration']>0x0){if(moment(_0x112fb9[_0x2f5a('0xf')])[_0x2f5a('0x17')](_0x4adae1[_0x2f5a('0x18')],'minutes')>moment()){return _0x1186a6(null,![],{'message':_0x2f5a('0x15')});}else{return utils['clearBlockUser'](_0x112fb9,_0x3cdc3a,![],null)[_0x2f5a('0xb')](function(){return _0x1186a6(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}}else{return _0x1186a6(null,![],{'message':_0x2f5a('0x15')});}}else{if(_0x3cdc3a>=_0x4adae1['allowedLoginAttempts']){return utils[_0x2f5a('0x19')](_0x112fb9,0x0,!![],moment())[_0x2f5a('0xb')](function(){return _0x1186a6(null,![],{'message':_0x2f5a('0x15')});});}else{return utils['clearBlockUser'](_0x112fb9,_0x3cdc3a,![],null)[_0x2f5a('0xb')](function(){return _0x1186a6(null,![],{'message':_0x2f5a('0x15')});});}}}else{return _0x1186a6(null,![],{'message':_0x2f5a('0x15')});}}else{if(_0x112fb9['disabled']){return _0x1186a6(null,![],{'message':_0x2f5a('0x15')});}else if(_0x4adae1[_0x2f5a('0xa')]>0x0){if(_0x112fb9['blocked']){if(_0x4adae1[_0x2f5a('0x18')]>0x0){if(moment(_0x112fb9[_0x2f5a('0xf')])['add'](_0x4adae1[_0x2f5a('0x18')],_0x2f5a('0x1a'))>moment()){return _0x1186a6(null,![],{'message':_0x2f5a('0x15')});}else{return utils['clearBlockUser'](_0x112fb9,0x0,![],null)[_0x2f5a('0xb')](function(){return utils[_0x2f5a('0x1b')](_0x112fb9);})[_0x2f5a('0xb')](function(){return _0x1186a6(null,_0x112fb9);});}}else{return _0x1186a6(null,![],{'message':_0x2f5a('0x15')});}}else{return utils['clearBlockUser'](_0x112fb9,0x0,![],null)[_0x2f5a('0xb')](function(){return utils['getLicense'](_0x112fb9);})[_0x2f5a('0xb')](function(){return _0x1186a6(null,_0x112fb9);})['catch'](function(_0x4470f4){return _0x1186a6(null,![],_0x4470f4);});}}else{if(_0x112fb9[_0x2f5a('0x1c')]){return _0x1186a6(null,![],{'message':_0x2f5a('0x15')});}else{return utils['getLicense'](_0x112fb9)['then'](function(){return _0x1186a6(null,_0x112fb9);});}}}});})['catch'](function(_0x416c24){return _0x1186a6(null,![],_0x416c24);});}function sendServiceMail(_0x3f5900){return db[_0x2f5a('0x1d')][_0x2f5a('0x1e')]({'where':{'service':!![]},'attributes':['id',_0x2f5a('0x14'),_0x2f5a('0x1f')],'include':[{'model':db[_0x2f5a('0x20')],'as':'Smtp','include':[{'model':db[_0x2f5a('0x21')],'as':_0x2f5a('0x21')}]}]})[_0x2f5a('0xb')](function(_0x502342){if(!_0x502342){throw new Error(_0x2f5a('0x22'));}var _0xd082c=_0x502342[_0x2f5a('0x23')]();var _0x597904={'account':_0xd082c,'message':_[_0x2f5a('0x24')]({'from':util[_0x2f5a('0x25')](_0x2f5a('0x26'),_0x502342[_0x2f5a('0x14')],_0x502342[_0x2f5a('0x1f')]||_0x502342[_0x2f5a('0x27')][_0x2f5a('0x12')])},_0x3f5900)};return client[_0x2f5a('0x28')]('SendMail',_0x597904);})['then'](function(_0x6f51f9){if(_0x6f51f9[_0x2f5a('0x29')]){throw new Error(util[_0x2f5a('0x25')](_0x2f5a('0x2a'),_0x6f51f9[_0x2f5a('0x29')][_0x2f5a('0x2b')]||JSON['stringify'](_0x6f51f9['error'])));}return!![];});}function handleError(_0x454afd,_0x1a1446,_0x5ec2e7){return _0x454afd[_0x2f5a('0x2c')](_0x1a1446||0x1f4)[_0x2f5a('0x2d')]({'message':_0x5ec2e7?_0x5ec2e7['message']||_0x5ec2e7:''});}exports[_0x2f5a('0x2e')]=function(_0x453127,_0x3a057b,_0x1cff3b){passport[_0x2f5a('0x16')](_0x2f5a('0x2f'),function(_0xdafc3a,_0x2958d4,_0x5f2410){var _0x32640c=_0xdafc3a||_0x5f2410;if(_0x32640c){return handleError(_0x3a057b,0x191,_0x32640c);}if(!_0x2958d4){return handleError(_0x3a057b,0x194,{'message':'Something\x20went\x20wrong,\x20please\x20try\x20again.'});}else{var _0x55b2d4={'payload':{'id':_0x2958d4['id'],'role':_0x2958d4[_0x2f5a('0xd')]},'options':{'expiresIn':0x15180}};return authService[_0x2f5a('0x30')](_0x55b2d4)[_0x2f5a('0xb')](function(_0x593144){_0x3a057b['json']({'id':_0x2958d4['id'],'token':_0x593144,'statusCall':'','isAlreadyLogged':_0x2958d4[_0x2f5a('0x31')]});});}})(_0x453127,_0x3a057b,_0x1cff3b);};exports[_0x2f5a('0x32')]=function(_0xe517df,_0x1f57bc){if(!_0xe517df[_0x2f5a('0x33')]['email']){return handleError(_0x1f57bc,0x1f4,{'message':_0x2f5a('0x34')});}var _0x32e11d=rs[_0x2f5a('0x35')]();_0xe517df[_0x2f5a('0x33')][_0x2f5a('0x1f')]=_0xe517df[_0x2f5a('0x33')][_0x2f5a('0x1f')][_0x2f5a('0x36')]()[_0x2f5a('0x37')]();var _0x51b6d5;return db['Setting'][_0x2f5a('0x9')]({'where':{'id':0x1},'attributes':[_0x2f5a('0xa'),'blockDuration'],'raw':!![]})['then'](function(_0x339708){_0x51b6d5=_0x339708;return db[_0x2f5a('0x38')][_0x2f5a('0x1e')]({'where':{'email':_0xe517df['body']['email']}});})[_0x2f5a('0xb')](function(_0x5ea25f){if(!_0x5ea25f){throw new Error(_0x2f5a('0x39'));}if(_0x5ea25f[_0x2f5a('0xe')]){throw new Error(_0x2f5a('0x3a'));}if(_0x5ea25f[_0x2f5a('0x1c')]){if(moment(_0x5ea25f[_0x2f5a('0xf')])[_0x2f5a('0x17')](_0x51b6d5['blockDuration'],_0x2f5a('0x1a'))>moment()){throw new Error(_0x2f5a('0x3b'));}else{_0x5ea25f[_0x2f5a('0x1c')]=![];_0x5ea25f[_0x2f5a('0xf')]=null;}}_0x5ea25f[_0x2f5a('0x3c')]=_0x32e11d;_0x5ea25f[_0x2f5a('0x3d')]=Date[_0x2f5a('0x3e')]()+0x36ee80;return _0x5ea25f[_0x2f5a('0x3f')]();})[_0x2f5a('0xb')](function(){return sendServiceMail({'to':_0xe517df[_0x2f5a('0x33')][_0x2f5a('0x1f')],'subject':_0x2f5a('0x40'),'text':_0x2f5a('0x41')+_0x2f5a('0x42')+_0x2f5a('0x43')+_0xe517df[_0x2f5a('0x44')][_0x2f5a('0x45')]+_0x2f5a('0x46')+_0x32e11d+'\x0a\x0a'+_0x2f5a('0x47')});})[_0x2f5a('0xb')](function(){_0x1f57bc[_0x2f5a('0x2c')](0xc8)[_0x2f5a('0x2d')]({'message':_0x2f5a('0x48')});})[_0x2f5a('0x49')](function(_0x496a17){return handleError(_0x1f57bc,0x1f4,_0x496a17);});};exports['reset']=function(_0x222707,_0x4cbb84){return db['User']['find']({'where':{'resetPasswordToken':_0x222707[_0x2f5a('0x4a')][_0x2f5a('0x4b')],'resetPasswordExpires':{'$gt':Date[_0x2f5a('0x3e')]()}}})[_0x2f5a('0xb')](function(_0x2cd422){if(!_0x2cd422){throw new Error(_0x2f5a('0x4c'));}return db['Setting'][_0x2f5a('0x9')]({'attributes':['id',_0x2f5a('0x4d'),_0x2f5a('0x4e'),_0x2f5a('0x4f')]})[_0x2f5a('0xb')](function(_0x16127c){if(_0x16127c[_0x2f5a('0x4d')])authService[_0x2f5a('0x50')](_0x222707[_0x2f5a('0x33')][_0x2f5a('0x51')]);if(!_0x16127c[_0x2f5a('0x4e')]||!_0x2cd422[_0x2f5a('0x52')])return _0x2cd422;authService[_0x2f5a('0x53')](_0x222707['body'][_0x2f5a('0x51')],_0x2cd422['previousPasswords'],_0x16127c['passwordHistoryLimit']);return _0x2cd422;})[_0x2f5a('0xb')](function(){_0x2cd422[_0x2f5a('0x51')]=_0x222707['body']['password'];_0x2cd422['resetPasswordToken']=null;_0x2cd422[_0x2f5a('0x3d')]=null;return _0x2cd422[_0x2f5a('0x3f')]();});})[_0x2f5a('0xb')](function(){_0x4cbb84[_0x2f5a('0x2c')](0xc8)['send']({'message':_0x2f5a('0x54')});})[_0x2f5a('0x49')](function(_0x3ed5e0){return handleError(_0x4cbb84,0x1f4,_0x3ed5e0);});};passport[_0x2f5a('0x55')]('local-login',new LocalStrategy({'usernameField':_0x2f5a('0x14'),'passwordField':'password'},function(_0x410a1e,_0x19985f,_0x4f7d77){return localAuthenticate(db[_0x2f5a('0x38')],_0x410a1e,_0x19985f,_0x4f7d77);}));
\ No newline at end of file
+var _0x83bb=['message','send','login','authenticate','Something\x20went\x20wrong,\x20please\x20try\x20again.','signToken','online','forgot','body','Email\x20parameter\x20is\x20missing','email','trim','toLowerCase','User','This\x20email\x20is\x20not\x20registered.','The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.','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','https://','headers','host','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','status','Reset\x20Email\x20sent!','reset','now','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','securePassword','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','previousPasswords','validatePasswordHistory','resetPasswordToken','use','local-login','util','passport','passport-local','Strategy','lodash','randomstring','../../mysqldb','client','http','Setting','findOne','then','name','password','salt','role','disabled','blocked','blockedAt','loginAttempts','admin','user','agent','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','allowedLoginAttempts','blockDuration','add','clearBlockUser','minutes','getLicense','catch','find','MailServerOut','CloudProvider','getSmtpOptions','format','Smtp','request','SendMail','error','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!'];(function(_0x3e8741,_0x40b2ad){var _0x8b0d66=function(_0x2c25ff){while(--_0x2c25ff){_0x3e8741['push'](_0x3e8741['shift']());}};_0x8b0d66(++_0x40b2ad);}(_0x83bb,0x1b7));var _0xb83b=function(_0xb05ed,_0x38964c){_0xb05ed=_0xb05ed-0x0;var _0x4ce84f=_0x83bb[_0xb05ed];return _0x4ce84f;};'use strict';var util=require(_0xb83b('0x0'));var passport=require(_0xb83b('0x1'));var LocalStrategy=require(_0xb83b('0x2'))[_0xb83b('0x3')];var jayson=require('jayson/promise');var _=require(_0xb83b('0x4'));var rs=require(_0xb83b('0x5'));var moment=require('moment');var db=require(_0xb83b('0x6'))['db'];var authService=require('../../components/auth/service');var utils=require('../../config/utils');var client=jayson[_0xb83b('0x7')][_0xb83b('0x8')]({'port':0x232b});function localAuthenticate(_0x292adb,_0x5c6dc9,_0x272d74,_0x1bb235){var _0x3ad566,_0x28049f;return db[_0xb83b('0x9')][_0xb83b('0xa')]({'where':{'id':0x1},'attributes':['allowedLoginAttempts','blockDuration'],'raw':!![]})[_0xb83b('0xb')](function(_0x48ec89){_0x3ad566=_0x48ec89;return _0x292adb['findOne']({'attributes':['id',_0xb83b('0xc'),_0xb83b('0xd'),_0xb83b('0xe'),_0xb83b('0xf'),_0xb83b('0x10'),_0xb83b('0x11'),_0xb83b('0x12'),_0xb83b('0x13')],'where':{'name':_0x5c6dc9,'role':{'$or':[_0xb83b('0x14'),_0xb83b('0x15'),_0xb83b('0x16')]}}});})[_0xb83b('0xb')](function(_0x1d0912){if(!_0x1d0912||_0x1d0912&&_0x1d0912[_0xb83b('0xc')]!==_0x5c6dc9){throw new Error(_0xb83b('0x17'));}else{_0x28049f=_0x1d0912;return _0x28049f;}})[_0xb83b('0xb')](function(){_0x28049f['authenticate'](_0x272d74,function(_0x510f88,_0x6147ff){var _0x4704a4=_0x28049f[_0xb83b('0x13')]+0x1;if(_0x510f88){return _0x1bb235(_0x510f88);}else if(!_0x6147ff){if(_0x28049f[_0xb83b('0x10')]){return _0x1bb235(null,![],{'message':_0xb83b('0x17')});}else if(_0x3ad566[_0xb83b('0x18')]>0x0){if(_0x28049f[_0xb83b('0x11')]){if(_0x3ad566[_0xb83b('0x19')]>0x0){if(moment(_0x28049f[_0xb83b('0x12')])[_0xb83b('0x1a')](_0x3ad566[_0xb83b('0x19')],'minutes')>moment()){return _0x1bb235(null,![],{'message':_0xb83b('0x17')});}else{return utils[_0xb83b('0x1b')](_0x28049f,_0x4704a4,![],null)[_0xb83b('0xb')](function(){return _0x1bb235(null,![],{'message':_0xb83b('0x17')});});}}else{return _0x1bb235(null,![],{'message':_0xb83b('0x17')});}}else{if(_0x4704a4>=_0x3ad566[_0xb83b('0x18')]){return utils[_0xb83b('0x1b')](_0x28049f,0x0,!![],moment())[_0xb83b('0xb')](function(){return _0x1bb235(null,![],{'message':_0xb83b('0x17')});});}else{return utils[_0xb83b('0x1b')](_0x28049f,_0x4704a4,![],null)[_0xb83b('0xb')](function(){return _0x1bb235(null,![],{'message':_0xb83b('0x17')});});}}}else{return _0x1bb235(null,![],{'message':_0xb83b('0x17')});}}else{if(_0x28049f[_0xb83b('0x10')]){return _0x1bb235(null,![],{'message':_0xb83b('0x17')});}else if(_0x3ad566[_0xb83b('0x18')]>0x0){if(_0x28049f['blocked']){if(_0x3ad566[_0xb83b('0x19')]>0x0){if(moment(_0x28049f[_0xb83b('0x12')])['add'](_0x3ad566[_0xb83b('0x19')],_0xb83b('0x1c'))>moment()){return _0x1bb235(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils[_0xb83b('0x1b')](_0x28049f,0x0,![],null)[_0xb83b('0xb')](function(){return utils['getLicense'](_0x28049f);})[_0xb83b('0xb')](function(){return _0x1bb235(null,_0x28049f);});}}else{return _0x1bb235(null,![],{'message':_0xb83b('0x17')});}}else{return utils[_0xb83b('0x1b')](_0x28049f,0x0,![],null)['then'](function(){return utils[_0xb83b('0x1d')](_0x28049f);})[_0xb83b('0xb')](function(){return _0x1bb235(null,_0x28049f);})[_0xb83b('0x1e')](function(_0x2b508b){return _0x1bb235(null,![],_0x2b508b);});}}else{if(_0x28049f[_0xb83b('0x11')]){return _0x1bb235(null,![],{'message':_0xb83b('0x17')});}else{return utils[_0xb83b('0x1d')](_0x28049f)[_0xb83b('0xb')](function(){return _0x1bb235(null,_0x28049f);});}}}});})[_0xb83b('0x1e')](function(_0x491b47){return _0x1bb235(null,![],_0x491b47);});}function sendServiceMail(_0x595d32){return db['MailAccount'][_0xb83b('0x1f')]({'where':{'service':!![]},'attributes':['id','name','email'],'include':[{'model':db[_0xb83b('0x20')],'as':'Smtp','include':[{'model':db[_0xb83b('0x21')],'as':_0xb83b('0x21')}]}]})[_0xb83b('0xb')](function(_0x5805e3){if(!_0x5805e3){throw new Error('Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!');}var _0xf67228=_0x5805e3[_0xb83b('0x22')]();var _0x3c393a={'account':_0xf67228,'message':_['merge']({'from':util[_0xb83b('0x23')]('\x22%s\x22\x20<%s>',_0x5805e3[_0xb83b('0xc')],_0x5805e3['email']||_0x5805e3[_0xb83b('0x24')]['user'])},_0x595d32)};return client[_0xb83b('0x25')](_0xb83b('0x26'),_0x3c393a);})[_0xb83b('0xb')](function(_0x13939d){if(_0x13939d[_0xb83b('0x27')]){throw new Error(util[_0xb83b('0x23')](_0xb83b('0x28'),_0x13939d['error'][_0xb83b('0x29')]||JSON['stringify'](_0x13939d[_0xb83b('0x27')])));}return!![];});}function handleError(_0x5cffc4,_0xdc32fe,_0x992ef6){return _0x5cffc4['status'](_0xdc32fe||0x1f4)[_0xb83b('0x2a')]({'message':_0x992ef6?_0x992ef6['message']||_0x992ef6:''});}exports[_0xb83b('0x2b')]=function(_0x3a568a,_0x41b7bd,_0x46f6df){passport[_0xb83b('0x2c')]('local-login',function(_0x5831cc,_0x167ec2,_0x1b7aac){var _0x2ffd48=_0x5831cc||_0x1b7aac;if(_0x2ffd48){return handleError(_0x41b7bd,0x191,_0x2ffd48);}if(!_0x167ec2){return handleError(_0x41b7bd,0x194,{'message':_0xb83b('0x2d')});}else{var _0x1adb0b={'payload':{'id':_0x167ec2['id'],'role':_0x167ec2['role']},'options':{'expiresIn':0x15180}};return authService[_0xb83b('0x2e')](_0x1adb0b)[_0xb83b('0xb')](function(_0x3a6c3b){_0x41b7bd['json']({'id':_0x167ec2['id'],'token':_0x3a6c3b,'statusCall':'','isAlreadyLogged':_0x167ec2[_0xb83b('0x2f')]});});}})(_0x3a568a,_0x41b7bd,_0x46f6df);};exports[_0xb83b('0x30')]=function(_0x248d39,_0x555546){if(!_0x248d39[_0xb83b('0x31')]['email']){return handleError(_0x555546,0x1f4,{'message':_0xb83b('0x32')});}var _0x42552a=rs['generate']();_0x248d39[_0xb83b('0x31')]['email']=_0x248d39['body'][_0xb83b('0x33')][_0xb83b('0x34')]()[_0xb83b('0x35')]();var _0x307e63;return db['Setting']['findOne']({'where':{'id':0x1},'attributes':[_0xb83b('0x18'),_0xb83b('0x19')],'raw':!![]})['then'](function(_0x5c0ac9){_0x307e63=_0x5c0ac9;return db[_0xb83b('0x36')]['find']({'where':{'email':_0x248d39['body'][_0xb83b('0x33')]}});})['then'](function(_0x5c0e6d){if(!_0x5c0e6d){throw new Error(_0xb83b('0x37'));}if(_0x5c0e6d['disabled']){throw new Error('The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.');}if(_0x5c0e6d['blocked']){if(moment(_0x5c0e6d['blockedAt'])['add'](_0x307e63['blockDuration'],_0xb83b('0x1c'))>moment()){throw new Error(_0xb83b('0x38'));}else{_0x5c0e6d[_0xb83b('0x11')]=![];_0x5c0e6d[_0xb83b('0x12')]=null;}}_0x5c0e6d['resetPasswordToken']=_0x42552a;_0x5c0e6d['resetPasswordExpires']=Date['now']()+0x36ee80;return _0x5c0e6d[_0xb83b('0x39')]();})[_0xb83b('0xb')](function(){return sendServiceMail({'to':_0x248d39[_0xb83b('0x31')][_0xb83b('0x33')],'subject':_0xb83b('0x3a'),'text':_0xb83b('0x3b')+_0xb83b('0x3c')+_0xb83b('0x3d')+_0x248d39[_0xb83b('0x3e')][_0xb83b('0x3f')]+_0xb83b('0x40')+_0x42552a+'\x0a\x0a'+_0xb83b('0x41')});})['then'](function(){_0x555546[_0xb83b('0x42')](0xc8)['send']({'message':_0xb83b('0x43')});})[_0xb83b('0x1e')](function(_0x4a3be9){return handleError(_0x555546,0x1f4,_0x4a3be9);});};exports[_0xb83b('0x44')]=function(_0x16ba19,_0x58ead1){return db['User'][_0xb83b('0x1f')]({'where':{'resetPasswordToken':_0x16ba19['params']['token'],'resetPasswordExpires':{'$gt':Date[_0xb83b('0x45')]()}}})[_0xb83b('0xb')](function(_0x207e95){if(!_0x207e95){throw new Error(_0xb83b('0x46'));}return db[_0xb83b('0x9')][_0xb83b('0xa')]({'attributes':['id',_0xb83b('0x47'),_0xb83b('0x48'),_0xb83b('0x49')]})[_0xb83b('0xb')](function(_0x128326){if(_0x128326['securePassword'])authService[_0xb83b('0x4a')](_0x16ba19[_0xb83b('0x31')][_0xb83b('0xd')]);if(!_0x128326[_0xb83b('0x48')]||!_0x207e95[_0xb83b('0x4b')])return _0x207e95;authService[_0xb83b('0x4c')](_0x16ba19['body'][_0xb83b('0xd')],_0x207e95[_0xb83b('0x4b')],_0x128326['passwordHistoryLimit']);return _0x207e95;})[_0xb83b('0xb')](function(){_0x207e95[_0xb83b('0xd')]=_0x16ba19[_0xb83b('0x31')][_0xb83b('0xd')];_0x207e95[_0xb83b('0x4d')]=null;_0x207e95['resetPasswordExpires']=null;return _0x207e95[_0xb83b('0x39')]();});})[_0xb83b('0xb')](function(){_0x58ead1[_0xb83b('0x42')](0xc8)[_0xb83b('0x2a')]({'message':'Password\x20reset!'});})[_0xb83b('0x1e')](function(_0x387635){return handleError(_0x58ead1,0x1f4,_0x387635);});};passport[_0xb83b('0x4e')](_0xb83b('0x4f'),new LocalStrategy({'usernameField':_0xb83b('0xc'),'passwordField':_0xb83b('0xd')},function(_0x2a8ee1,_0x2230dc,_0x8ae610){return localAuthenticate(db['User'],_0x2a8ee1,_0x2230dc,_0x8ae610);}));
\ No newline at end of file