Built motion from commit 013e4bb4.|2.6.18
[motion2.git] / server / api / authLocal / authLocal.controller.js
index 351a410..7d7c932 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xffcc=['token','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','securePassword','enforcePasswordHistory','passwordHistoryLimit','validatePasswordHistory','previousPasswords','use','util','passport','Strategy','jayson/promise','moment','../../mysqldb','../../config/utils','client','http','Setting','findOne','allowedLoginAttempts','blockDuration','name','password','salt','role','blocked','blockedAt','loginAttempts','admin','user','agent','then','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','authenticate','disabled','add','minutes','clearBlockUser','getLicense','catch','MailAccount','find','email','MailServerOut','Smtp','CloudProvider','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','getSmtpOptions','merge','format','request','error','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','message','status','send','login','local-login','json','online','forgot','body','generate','trim','toLowerCase','User','This\x20email\x20is\x20not\x20registered.','The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.','resetPasswordToken','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','https://','headers','host','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','Reset\x20Email\x20sent!','reset','params'];(function(_0x26f0a5,_0x532bb5){var _0x43557b=function(_0x6e72d3){while(--_0x6e72d3){_0x26f0a5['push'](_0x26f0a5['shift']());}};_0x43557b(++_0x532bb5);}(_0xffcc,0x1ee));var _0xcffc=function(_0x4fa271,_0x4415a1){_0x4fa271=_0x4fa271-0x0;var _0x5c5b72=_0xffcc[_0x4fa271];return _0x5c5b72;};'use strict';var util=require(_0xcffc('0x0'));var passport=require(_0xcffc('0x1'));var LocalStrategy=require('passport-local')[_0xcffc('0x2')];var jayson=require(_0xcffc('0x3'));var _=require('lodash');var rs=require('randomstring');var moment=require(_0xcffc('0x4'));var db=require(_0xcffc('0x5'))['db'];var authService=require('../../components/auth/service');var utils=require(_0xcffc('0x6'));var client=jayson[_0xcffc('0x7')][_0xcffc('0x8')]({'port':0x232b});function localAuthenticate(_0x2d59e6,_0x192be6,_0x2fd1dd,_0x2e4edd){var _0xfa516,_0x11fca0;return db[_0xcffc('0x9')][_0xcffc('0xa')]({'where':{'id':0x1},'attributes':[_0xcffc('0xb'),_0xcffc('0xc')],'raw':!![]})['then'](function(_0x49f9c5){_0xfa516=_0x49f9c5;return _0x2d59e6[_0xcffc('0xa')]({'attributes':['id',_0xcffc('0xd'),_0xcffc('0xe'),_0xcffc('0xf'),_0xcffc('0x10'),'disabled',_0xcffc('0x11'),_0xcffc('0x12'),_0xcffc('0x13')],'where':{'name':_0x192be6,'role':{'$or':[_0xcffc('0x14'),_0xcffc('0x15'),_0xcffc('0x16')]}}});})[_0xcffc('0x17')](function(_0x657f2f){if(!_0x657f2f||_0x657f2f&&_0x657f2f[_0xcffc('0xd')]!==_0x192be6){throw new Error(_0xcffc('0x18'));}else{_0x11fca0=_0x657f2f;return _0x11fca0;}})['then'](function(){_0x11fca0[_0xcffc('0x19')](_0x2fd1dd,function(_0x40bf3f,_0x133df4){var _0x1b2081=_0x11fca0[_0xcffc('0x13')]+0x1;if(_0x40bf3f){return _0x2e4edd(_0x40bf3f);}else if(!_0x133df4){if(_0x11fca0[_0xcffc('0x1a')]){return _0x2e4edd(null,![],{'message':_0xcffc('0x18')});}else if(_0xfa516[_0xcffc('0xb')]>0x0){if(_0x11fca0[_0xcffc('0x11')]){if(_0xfa516[_0xcffc('0xc')]>0x0){if(moment(_0x11fca0['blockedAt'])[_0xcffc('0x1b')](_0xfa516[_0xcffc('0xc')],_0xcffc('0x1c'))>moment()){return _0x2e4edd(null,![],{'message':_0xcffc('0x18')});}else{return utils[_0xcffc('0x1d')](_0x11fca0,_0x1b2081,![],null)[_0xcffc('0x17')](function(){return _0x2e4edd(null,![],{'message':_0xcffc('0x18')});});}}else{return _0x2e4edd(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{if(_0x1b2081>=_0xfa516[_0xcffc('0xb')]){return utils[_0xcffc('0x1d')](_0x11fca0,0x0,!![],moment())[_0xcffc('0x17')](function(){return _0x2e4edd(null,![],{'message':_0xcffc('0x18')});});}else{return utils[_0xcffc('0x1d')](_0x11fca0,_0x1b2081,![],null)['then'](function(){return _0x2e4edd(null,![],{'message':_0xcffc('0x18')});});}}}else{return _0x2e4edd(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{if(_0x11fca0[_0xcffc('0x1a')]){return _0x2e4edd(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else if(_0xfa516[_0xcffc('0xb')]>0x0){if(_0x11fca0[_0xcffc('0x11')]){if(_0xfa516[_0xcffc('0xc')]>0x0){if(moment(_0x11fca0[_0xcffc('0x12')])[_0xcffc('0x1b')](_0xfa516['blockDuration'],_0xcffc('0x1c'))>moment()){return _0x2e4edd(null,![],{'message':_0xcffc('0x18')});}else{return utils[_0xcffc('0x1d')](_0x11fca0,0x0,![],null)[_0xcffc('0x17')](function(){return utils[_0xcffc('0x1e')](_0x11fca0);})[_0xcffc('0x17')](function(){return _0x2e4edd(null,_0x11fca0);});}}else{return _0x2e4edd(null,![],{'message':_0xcffc('0x18')});}}else{return utils[_0xcffc('0x1d')](_0x11fca0,0x0,![],null)[_0xcffc('0x17')](function(){return utils[_0xcffc('0x1e')](_0x11fca0);})[_0xcffc('0x17')](function(){return _0x2e4edd(null,_0x11fca0);})['catch'](function(_0x4cdbba){return _0x2e4edd(null,![],_0x4cdbba);});}}else{if(_0x11fca0[_0xcffc('0x11')]){return _0x2e4edd(null,![],{'message':_0xcffc('0x18')});}else{return utils[_0xcffc('0x1e')](_0x11fca0)[_0xcffc('0x17')](function(){return _0x2e4edd(null,_0x11fca0);});}}}});})[_0xcffc('0x1f')](function(_0x396d4b){return _0x2e4edd(null,![],_0x396d4b);});}function sendServiceMail(_0x55975a){return db[_0xcffc('0x20')][_0xcffc('0x21')]({'where':{'service':!![]},'attributes':['id',_0xcffc('0xd'),_0xcffc('0x22')],'include':[{'model':db[_0xcffc('0x23')],'as':_0xcffc('0x24'),'include':[{'model':db['CloudProvider'],'as':_0xcffc('0x25')}]}]})[_0xcffc('0x17')](function(_0x255749){if(!_0x255749){throw new Error(_0xcffc('0x26'));}var _0x50b567=_0x255749[_0xcffc('0x27')]();var _0x39f617={'account':_0x50b567,'message':_[_0xcffc('0x28')]({'from':util[_0xcffc('0x29')]('\x22%s\x22\x20<%s>',_0x255749['name'],_0x255749[_0xcffc('0x22')]||_0x255749[_0xcffc('0x24')][_0xcffc('0x15')])},_0x55975a)};return client[_0xcffc('0x2a')]('SendMail',_0x39f617);})['then'](function(_0x9b4891){if(_0x9b4891[_0xcffc('0x2b')]){throw new Error(util[_0xcffc('0x29')](_0xcffc('0x2c'),_0x9b4891[_0xcffc('0x2b')][_0xcffc('0x2d')]||JSON['stringify'](_0x9b4891['error'])));}return!![];});}function handleError(_0x29134f,_0x851f6b,_0x36a7d4){return _0x29134f[_0xcffc('0x2e')](_0x851f6b||0x1f4)[_0xcffc('0x2f')]({'message':_0x36a7d4?_0x36a7d4[_0xcffc('0x2d')]||_0x36a7d4:''});}exports[_0xcffc('0x30')]=function(_0x12a7ef,_0x1beff2,_0x213e45){passport[_0xcffc('0x19')](_0xcffc('0x31'),function(_0x1e48ff,_0x53594b,_0x19b160){var _0x1245a6=_0x1e48ff||_0x19b160;if(_0x1245a6){return handleError(_0x1beff2,0x191,_0x1245a6);}if(!_0x53594b){return handleError(_0x1beff2,0x194,{'message':'Something\x20went\x20wrong,\x20please\x20try\x20again.'});}else{var _0x20426f={'payload':{'id':_0x53594b['id'],'role':_0x53594b[_0xcffc('0x10')]},'options':{'expiresIn':0x15180}};return authService['signToken'](_0x20426f)[_0xcffc('0x17')](function(_0x251eb4){_0x1beff2[_0xcffc('0x32')]({'id':_0x53594b['id'],'token':_0x251eb4,'statusCall':'','isAlreadyLogged':_0x53594b[_0xcffc('0x33')]});});}})(_0x12a7ef,_0x1beff2,_0x213e45);};exports[_0xcffc('0x34')]=function(_0x1af359,_0x370942){if(!_0x1af359[_0xcffc('0x35')][_0xcffc('0x22')]){return handleError(_0x370942,0x1f4,{'message':'Email\x20parameter\x20is\x20missing'});}var _0x3764f2=rs[_0xcffc('0x36')]();_0x1af359[_0xcffc('0x35')][_0xcffc('0x22')]=_0x1af359[_0xcffc('0x35')][_0xcffc('0x22')][_0xcffc('0x37')]()[_0xcffc('0x38')]();var _0x515de3;return db[_0xcffc('0x9')][_0xcffc('0xa')]({'where':{'id':0x1},'attributes':[_0xcffc('0xb'),_0xcffc('0xc')],'raw':!![]})[_0xcffc('0x17')](function(_0x495464){_0x515de3=_0x495464;return db[_0xcffc('0x39')]['find']({'where':{'email':_0x1af359[_0xcffc('0x35')][_0xcffc('0x22')]}});})[_0xcffc('0x17')](function(_0x2169dd){if(!_0x2169dd){throw new Error(_0xcffc('0x3a'));}if(_0x2169dd[_0xcffc('0x1a')]){throw new Error('The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.');}if(_0x2169dd[_0xcffc('0x11')]){if(moment(_0x2169dd[_0xcffc('0x12')])[_0xcffc('0x1b')](_0x515de3['blockDuration'],_0xcffc('0x1c'))>moment()){throw new Error(_0xcffc('0x3b'));}else{_0x2169dd[_0xcffc('0x11')]=![];_0x2169dd[_0xcffc('0x12')]=null;}}_0x2169dd[_0xcffc('0x3c')]=_0x3764f2;_0x2169dd[_0xcffc('0x3d')]=Date['now']()+0x36ee80;return _0x2169dd[_0xcffc('0x3e')]();})[_0xcffc('0x17')](function(){return sendServiceMail({'to':_0x1af359[_0xcffc('0x35')][_0xcffc('0x22')],'subject':_0xcffc('0x3f'),'text':_0xcffc('0x40')+_0xcffc('0x41')+_0xcffc('0x42')+_0x1af359[_0xcffc('0x43')][_0xcffc('0x44')]+'/reset/'+_0x3764f2+'\x0a\x0a'+_0xcffc('0x45')});})[_0xcffc('0x17')](function(){_0x370942[_0xcffc('0x2e')](0xc8)[_0xcffc('0x2f')]({'message':_0xcffc('0x46')});})[_0xcffc('0x1f')](function(_0x2fb795){return handleError(_0x370942,0x1f4,_0x2fb795);});};exports[_0xcffc('0x47')]=function(_0xc5c8ce,_0x3cbc81){return db[_0xcffc('0x39')]['find']({'where':{'resetPasswordToken':_0xc5c8ce[_0xcffc('0x48')][_0xcffc('0x49')],'resetPasswordExpires':{'$gt':Date['now']()}}})[_0xcffc('0x17')](function(_0x4f7851){if(!_0x4f7851){throw new Error(_0xcffc('0x4a'));}return db[_0xcffc('0x9')][_0xcffc('0xa')]({'attributes':['id',_0xcffc('0x4b'),_0xcffc('0x4c'),_0xcffc('0x4d')]})[_0xcffc('0x17')](function(_0x2f3a1b){if(_0x2f3a1b['securePassword'])authService['validatePasswordPattern'](_0xc5c8ce[_0xcffc('0x35')][_0xcffc('0xe')]);if(!_0x2f3a1b['enforcePasswordHistory']||!_0x4f7851['previousPasswords'])return _0x4f7851;authService[_0xcffc('0x4e')](_0xc5c8ce['body'][_0xcffc('0xe')],_0x4f7851[_0xcffc('0x4f')],_0x2f3a1b['passwordHistoryLimit']);return _0x4f7851;})[_0xcffc('0x17')](function(){_0x4f7851[_0xcffc('0xe')]=_0xc5c8ce[_0xcffc('0x35')][_0xcffc('0xe')];_0x4f7851[_0xcffc('0x3c')]=null;_0x4f7851[_0xcffc('0x3d')]=null;return _0x4f7851['save']();});})[_0xcffc('0x17')](function(){_0x3cbc81[_0xcffc('0x2e')](0xc8)['send']({'message':'Password\x20reset!'});})[_0xcffc('0x1f')](function(_0x118daf){return handleError(_0x3cbc81,0x1f4,_0x118daf);});};passport[_0xcffc('0x50')](_0xcffc('0x31'),new LocalStrategy({'usernameField':_0xcffc('0xd'),'passwordField':_0xcffc('0xe')},function(_0x488294,_0x528a11,_0x172d15){return localAuthenticate(db[_0xcffc('0x39')],_0x488294,_0x528a11,_0x172d15);}));
\ No newline at end of file
+var _0xe0af=['blockedAt','loginAttempts','admin','user','agent','authenticate','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','add','minutes','clearBlockUser','getLicense','catch','MailAccount','find','email','Smtp','CloudProvider','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','getSmtpOptions','merge','\x22%s\x22\x20<%s>','request','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','error','message','status','send','login','local-login','Something\x20went\x20wrong,\x20please\x20try\x20again.','signToken','json','online','body','Email\x20parameter\x20is\x20missing','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','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://','host','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','reset','User','token','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','securePassword','enforcePasswordHistory','validatePasswordPattern','password','validatePasswordHistory','save','Password\x20reset!','use','util','Strategy','lodash','randomstring','../../mysqldb','../../components/auth/service','../../config/utils','client','http','Setting','findOne','allowedLoginAttempts','blockDuration','then','name','salt','role','disabled','blocked'];(function(_0x4da8bf,_0x166c11){var _0x13c514=function(_0x521e1e){while(--_0x521e1e){_0x4da8bf['push'](_0x4da8bf['shift']());}};_0x13c514(++_0x166c11);}(_0xe0af,0xda));var _0xfe0a=function(_0x19cb1a,_0x4ce1b2){_0x19cb1a=_0x19cb1a-0x0;var _0x399650=_0xe0af[_0x19cb1a];return _0x399650;};'use strict';var util=require(_0xfe0a('0x0'));var passport=require('passport');var LocalStrategy=require('passport-local')[_0xfe0a('0x1')];var jayson=require('jayson/promise');var _=require(_0xfe0a('0x2'));var rs=require(_0xfe0a('0x3'));var moment=require('moment');var db=require(_0xfe0a('0x4'))['db'];var authService=require(_0xfe0a('0x5'));var utils=require(_0xfe0a('0x6'));var client=jayson[_0xfe0a('0x7')][_0xfe0a('0x8')]({'port':0x232b});function localAuthenticate(_0x168527,_0x421e55,_0x1ce022,_0x30952b){var _0x154ec9,_0x43a159;return db[_0xfe0a('0x9')][_0xfe0a('0xa')]({'where':{'id':0x1},'attributes':[_0xfe0a('0xb'),_0xfe0a('0xc')],'raw':!![]})[_0xfe0a('0xd')](function(_0x2069c2){_0x154ec9=_0x2069c2;return _0x168527['findOne']({'attributes':['id',_0xfe0a('0xe'),'password',_0xfe0a('0xf'),_0xfe0a('0x10'),_0xfe0a('0x11'),_0xfe0a('0x12'),_0xfe0a('0x13'),_0xfe0a('0x14')],'where':{'name':_0x421e55,'role':{'$or':[_0xfe0a('0x15'),_0xfe0a('0x16'),_0xfe0a('0x17')]}}});})[_0xfe0a('0xd')](function(_0x3ca9dd){if(!_0x3ca9dd||_0x3ca9dd&&_0x3ca9dd[_0xfe0a('0xe')]!==_0x421e55){throw new Error('Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.');}else{_0x43a159=_0x3ca9dd;return _0x43a159;}})['then'](function(){_0x43a159[_0xfe0a('0x18')](_0x1ce022,function(_0x2f5b6d,_0x5f08bd){var _0xaecaf4=_0x43a159[_0xfe0a('0x14')]+0x1;if(_0x2f5b6d){return _0x30952b(_0x2f5b6d);}else if(!_0x5f08bd){if(_0x43a159[_0xfe0a('0x11')]){return _0x30952b(null,![],{'message':_0xfe0a('0x19')});}else if(_0x154ec9['allowedLoginAttempts']>0x0){if(_0x43a159[_0xfe0a('0x12')]){if(_0x154ec9[_0xfe0a('0xc')]>0x0){if(moment(_0x43a159[_0xfe0a('0x13')])[_0xfe0a('0x1a')](_0x154ec9[_0xfe0a('0xc')],_0xfe0a('0x1b'))>moment()){return _0x30952b(null,![],{'message':_0xfe0a('0x19')});}else{return utils[_0xfe0a('0x1c')](_0x43a159,_0xaecaf4,![],null)[_0xfe0a('0xd')](function(){return _0x30952b(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}}else{return _0x30952b(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{if(_0xaecaf4>=_0x154ec9[_0xfe0a('0xb')]){return utils[_0xfe0a('0x1c')](_0x43a159,0x0,!![],moment())[_0xfe0a('0xd')](function(){return _0x30952b(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}else{return utils[_0xfe0a('0x1c')](_0x43a159,_0xaecaf4,![],null)[_0xfe0a('0xd')](function(){return _0x30952b(null,![],{'message':_0xfe0a('0x19')});});}}}else{return _0x30952b(null,![],{'message':_0xfe0a('0x19')});}}else{if(_0x43a159[_0xfe0a('0x11')]){return _0x30952b(null,![],{'message':_0xfe0a('0x19')});}else if(_0x154ec9['allowedLoginAttempts']>0x0){if(_0x43a159['blocked']){if(_0x154ec9['blockDuration']>0x0){if(moment(_0x43a159['blockedAt'])['add'](_0x154ec9[_0xfe0a('0xc')],_0xfe0a('0x1b'))>moment()){return _0x30952b(null,![],{'message':_0xfe0a('0x19')});}else{return utils[_0xfe0a('0x1c')](_0x43a159,0x0,![],null)[_0xfe0a('0xd')](function(){return utils[_0xfe0a('0x1d')](_0x43a159);})[_0xfe0a('0xd')](function(){return _0x30952b(null,_0x43a159);});}}else{return _0x30952b(null,![],{'message':_0xfe0a('0x19')});}}else{return utils[_0xfe0a('0x1c')](_0x43a159,0x0,![],null)['then'](function(){return utils['getLicense'](_0x43a159);})[_0xfe0a('0xd')](function(){return _0x30952b(null,_0x43a159);})[_0xfe0a('0x1e')](function(_0x5d8dce){return _0x30952b(null,![],_0x5d8dce);});}}else{if(_0x43a159[_0xfe0a('0x12')]){return _0x30952b(null,![],{'message':_0xfe0a('0x19')});}else{return utils[_0xfe0a('0x1d')](_0x43a159)['then'](function(){return _0x30952b(null,_0x43a159);});}}}});})[_0xfe0a('0x1e')](function(_0x50d298){return _0x30952b(null,![],_0x50d298);});}function sendServiceMail(_0x4f54e2){return db[_0xfe0a('0x1f')][_0xfe0a('0x20')]({'where':{'service':!![]},'attributes':['id',_0xfe0a('0xe'),_0xfe0a('0x21')],'include':[{'model':db['MailServerOut'],'as':_0xfe0a('0x22'),'include':[{'model':db[_0xfe0a('0x23')],'as':_0xfe0a('0x23')}]}]})[_0xfe0a('0xd')](function(_0x117f84){if(!_0x117f84){throw new Error(_0xfe0a('0x24'));}var _0x10bb3e=_0x117f84[_0xfe0a('0x25')]();var _0x164dbb={'account':_0x10bb3e,'message':_[_0xfe0a('0x26')]({'from':util['format'](_0xfe0a('0x27'),_0x117f84[_0xfe0a('0xe')],_0x117f84[_0xfe0a('0x21')]||_0x117f84[_0xfe0a('0x22')]['user'])},_0x4f54e2)};return client[_0xfe0a('0x28')]('SendMail',_0x164dbb);})[_0xfe0a('0xd')](function(_0x2e07f6){if(_0x2e07f6['error']){throw new Error(util['format'](_0xfe0a('0x29'),_0x2e07f6[_0xfe0a('0x2a')][_0xfe0a('0x2b')]||JSON['stringify'](_0x2e07f6['error'])));}return!![];});}function handleError(_0x116814,_0x434520,_0x5d2990){return _0x116814[_0xfe0a('0x2c')](_0x434520||0x1f4)[_0xfe0a('0x2d')]({'message':_0x5d2990?_0x5d2990[_0xfe0a('0x2b')]||_0x5d2990:''});}exports[_0xfe0a('0x2e')]=function(_0x3fdd7a,_0x31f074,_0x41e0f6){passport[_0xfe0a('0x18')](_0xfe0a('0x2f'),function(_0xe6b41f,_0x57d5b1,_0x39ab18){var _0x5322f2=_0xe6b41f||_0x39ab18;if(_0x5322f2){return handleError(_0x31f074,0x191,_0x5322f2);}if(!_0x57d5b1){return handleError(_0x31f074,0x194,{'message':_0xfe0a('0x30')});}else{var _0x1a40ac={'payload':{'id':_0x57d5b1['id'],'role':_0x57d5b1[_0xfe0a('0x10')]},'options':{'expiresIn':0x15180}};return authService[_0xfe0a('0x31')](_0x1a40ac)['then'](function(_0x5bbeea){_0x31f074[_0xfe0a('0x32')]({'id':_0x57d5b1['id'],'token':_0x5bbeea,'statusCall':'','isAlreadyLogged':_0x57d5b1[_0xfe0a('0x33')]});});}})(_0x3fdd7a,_0x31f074,_0x41e0f6);};exports['forgot']=function(_0x4f3c23,_0xfcb89e){if(!_0x4f3c23[_0xfe0a('0x34')][_0xfe0a('0x21')]){return handleError(_0xfcb89e,0x1f4,{'message':_0xfe0a('0x35')});}var _0x44c0c0=rs['generate']();_0x4f3c23[_0xfe0a('0x34')][_0xfe0a('0x21')]=_0x4f3c23[_0xfe0a('0x34')]['email'][_0xfe0a('0x36')]()['toLowerCase']();var _0x4692bb;return db[_0xfe0a('0x9')]['findOne']({'where':{'id':0x1},'attributes':['allowedLoginAttempts',_0xfe0a('0xc')],'raw':!![]})[_0xfe0a('0xd')](function(_0x1870e8){_0x4692bb=_0x1870e8;return db['User'][_0xfe0a('0x20')]({'where':{'email':_0x4f3c23['body'][_0xfe0a('0x21')]}});})[_0xfe0a('0xd')](function(_0x2cbbe2){if(!_0x2cbbe2){throw new Error(_0xfe0a('0x37'));}if(_0x2cbbe2['disabled']){throw new Error(_0xfe0a('0x38'));}if(_0x2cbbe2['blocked']){if(moment(_0x2cbbe2[_0xfe0a('0x13')])[_0xfe0a('0x1a')](_0x4692bb[_0xfe0a('0xc')],_0xfe0a('0x1b'))>moment()){throw new Error(_0xfe0a('0x39'));}else{_0x2cbbe2[_0xfe0a('0x12')]=![];_0x2cbbe2[_0xfe0a('0x13')]=null;}}_0x2cbbe2[_0xfe0a('0x3a')]=_0x44c0c0;_0x2cbbe2[_0xfe0a('0x3b')]=Date[_0xfe0a('0x3c')]()+0x36ee80;return _0x2cbbe2['save']();})[_0xfe0a('0xd')](function(){return sendServiceMail({'to':_0x4f3c23['body']['email'],'subject':'xCally\x20Motion\x20Password\x20Reset','text':_0xfe0a('0x3d')+_0xfe0a('0x3e')+_0xfe0a('0x3f')+_0x4f3c23['headers'][_0xfe0a('0x40')]+_0xfe0a('0x41')+_0x44c0c0+'\x0a\x0a'+_0xfe0a('0x42')});})['then'](function(){_0xfcb89e[_0xfe0a('0x2c')](0xc8)[_0xfe0a('0x2d')]({'message':'Reset\x20Email\x20sent!'});})[_0xfe0a('0x1e')](function(_0x26caad){return handleError(_0xfcb89e,0x1f4,_0x26caad);});};exports[_0xfe0a('0x43')]=function(_0x263a2c,_0x4d93ee){return db[_0xfe0a('0x44')]['find']({'where':{'resetPasswordToken':_0x263a2c['params'][_0xfe0a('0x45')],'resetPasswordExpires':{'$gt':Date[_0xfe0a('0x3c')]()}}})[_0xfe0a('0xd')](function(_0x3a2b79){if(!_0x3a2b79){throw new Error(_0xfe0a('0x46'));}return db[_0xfe0a('0x9')][_0xfe0a('0xa')]({'attributes':['id',_0xfe0a('0x47'),_0xfe0a('0x48'),'passwordHistoryLimit']})['then'](function(_0xcf0012){if(_0xcf0012[_0xfe0a('0x47')])authService[_0xfe0a('0x49')](_0x263a2c[_0xfe0a('0x34')][_0xfe0a('0x4a')]);if(!_0xcf0012['enforcePasswordHistory']||!_0x3a2b79['previousPasswords'])return _0x3a2b79;authService[_0xfe0a('0x4b')](_0x263a2c['body'][_0xfe0a('0x4a')],_0x3a2b79['previousPasswords'],_0xcf0012['passwordHistoryLimit']);return _0x3a2b79;})['then'](function(){_0x3a2b79['password']=_0x263a2c[_0xfe0a('0x34')]['password'];_0x3a2b79[_0xfe0a('0x3a')]=null;_0x3a2b79[_0xfe0a('0x3b')]=null;return _0x3a2b79[_0xfe0a('0x4c')]();});})['then'](function(){_0x4d93ee[_0xfe0a('0x2c')](0xc8)[_0xfe0a('0x2d')]({'message':_0xfe0a('0x4d')});})[_0xfe0a('0x1e')](function(_0x85aad5){return handleError(_0x4d93ee,0x1f4,_0x85aad5);});};passport[_0xfe0a('0x4e')](_0xfe0a('0x2f'),new LocalStrategy({'usernameField':'name','passwordField':_0xfe0a('0x4a')},function(_0x2bad59,_0x215904,_0x549441){return localAuthenticate(db['User'],_0x2bad59,_0x215904,_0x549441);}));
\ No newline at end of file