Built motion from commit a8c4dd89.|2.6.33
[motion2.git] / server / api / authLocal / authLocal.controller.js
index a523108..966835f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb000=['Something\x20went\x20wrong,\x20please\x20try\x20again.','signToken','json','online','forgot','body','Email\x20parameter\x20is\x20missing','generate','trim','toLowerCase','This\x20email\x20is\x20not\x20registered.','The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.','resetPasswordToken','resetPasswordExpires','now','save','https://','headers','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','send','params','token','securePassword','enforcePasswordHistory','passwordHistoryLimit','validatePasswordPattern','previousPasswords','validatePasswordHistory','use','User','passport-local','Strategy','jayson/promise','randomstring','moment','../../mysqldb','../../components/auth/service','../../config/utils','client','http','Setting','findOne','allowedLoginAttempts','blockDuration','then','name','password','salt','role','disabled','blockedAt','loginAttempts','admin','authenticate','blocked','add','minutes','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','clearBlockUser','getLicense','catch','MailAccount','find','email','MailServerOut','Smtp','CloudProvider','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','merge','format','\x22%s\x22\x20<%s>','SendMail','error','message','stringify','status','login','local-login'];(function(_0x38e024,_0x3615aa){var _0x1e0118=function(_0x172e68){while(--_0x172e68){_0x38e024['push'](_0x38e024['shift']());}};_0x1e0118(++_0x3615aa);}(_0xb000,0xbd));var _0x0b00=function(_0x5ac84c,_0x287781){_0x5ac84c=_0x5ac84c-0x0;var _0x3c53d2=_0xb000[_0x5ac84c];return _0x3c53d2;};'use strict';var util=require('util');var passport=require('passport');var LocalStrategy=require(_0x0b00('0x0'))[_0x0b00('0x1')];var jayson=require(_0x0b00('0x2'));var _=require('lodash');var rs=require(_0x0b00('0x3'));var moment=require(_0x0b00('0x4'));var db=require(_0x0b00('0x5'))['db'];var authService=require(_0x0b00('0x6'));var utils=require(_0x0b00('0x7'));var client=jayson[_0x0b00('0x8')][_0x0b00('0x9')]({'port':0x232b});function localAuthenticate(_0x3d6de7,_0x3a9380,_0x33254b,_0x58472e){var _0x111e42,_0x4a4d4c;return db[_0x0b00('0xa')][_0x0b00('0xb')]({'where':{'id':0x1},'attributes':[_0x0b00('0xc'),_0x0b00('0xd')],'raw':!![]})[_0x0b00('0xe')](function(_0x5e1b6b){_0x111e42=_0x5e1b6b;return _0x3d6de7[_0x0b00('0xb')]({'attributes':['id',_0x0b00('0xf'),_0x0b00('0x10'),_0x0b00('0x11'),_0x0b00('0x12'),_0x0b00('0x13'),'blocked',_0x0b00('0x14'),_0x0b00('0x15')],'where':{'name':_0x3a9380,'role':{'$or':[_0x0b00('0x16'),'user','agent']}}});})[_0x0b00('0xe')](function(_0x2e56b8){if(!_0x2e56b8||_0x2e56b8&&_0x2e56b8['name']!==_0x3a9380){throw new Error('Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.');}else{_0x4a4d4c=_0x2e56b8;return _0x4a4d4c;}})[_0x0b00('0xe')](function(){_0x4a4d4c[_0x0b00('0x17')](_0x33254b,function(_0x397bd2,_0x54aaa1){var _0x16da93=_0x4a4d4c[_0x0b00('0x15')]+0x1;if(_0x397bd2){return _0x58472e(_0x397bd2);}else if(!_0x54aaa1){if(_0x4a4d4c['disabled']){return _0x58472e(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else if(_0x111e42['allowedLoginAttempts']>0x0){if(_0x4a4d4c[_0x0b00('0x18')]){if(_0x111e42[_0x0b00('0xd')]>0x0){if(moment(_0x4a4d4c[_0x0b00('0x14')])[_0x0b00('0x19')](_0x111e42[_0x0b00('0xd')],_0x0b00('0x1a'))>moment()){return _0x58472e(null,![],{'message':_0x0b00('0x1b')});}else{return utils[_0x0b00('0x1c')](_0x4a4d4c,_0x16da93,![],null)[_0x0b00('0xe')](function(){return _0x58472e(null,![],{'message':_0x0b00('0x1b')});});}}else{return _0x58472e(null,![],{'message':_0x0b00('0x1b')});}}else{if(_0x16da93>=_0x111e42[_0x0b00('0xc')]){return utils['clearBlockUser'](_0x4a4d4c,0x0,!![],moment())[_0x0b00('0xe')](function(){return _0x58472e(null,![],{'message':_0x0b00('0x1b')});});}else{return utils[_0x0b00('0x1c')](_0x4a4d4c,_0x16da93,![],null)[_0x0b00('0xe')](function(){return _0x58472e(null,![],{'message':_0x0b00('0x1b')});});}}}else{return _0x58472e(null,![],{'message':_0x0b00('0x1b')});}}else{if(_0x4a4d4c[_0x0b00('0x13')]){return _0x58472e(null,![],{'message':_0x0b00('0x1b')});}else if(_0x111e42[_0x0b00('0xc')]>0x0){if(_0x4a4d4c[_0x0b00('0x18')]){if(_0x111e42[_0x0b00('0xd')]>0x0){if(moment(_0x4a4d4c[_0x0b00('0x14')])['add'](_0x111e42[_0x0b00('0xd')],'minutes')>moment()){return _0x58472e(null,![],{'message':_0x0b00('0x1b')});}else{return utils['clearBlockUser'](_0x4a4d4c,0x0,![],null)[_0x0b00('0xe')](function(){return utils[_0x0b00('0x1d')](_0x4a4d4c);})[_0x0b00('0xe')](function(){return _0x58472e(null,_0x4a4d4c);});}}else{return _0x58472e(null,![],{'message':_0x0b00('0x1b')});}}else{return utils['clearBlockUser'](_0x4a4d4c,0x0,![],null)[_0x0b00('0xe')](function(){return utils[_0x0b00('0x1d')](_0x4a4d4c);})[_0x0b00('0xe')](function(){return _0x58472e(null,_0x4a4d4c);})[_0x0b00('0x1e')](function(_0x37e626){return _0x58472e(null,![],_0x37e626);});}}else{if(_0x4a4d4c['blocked']){return _0x58472e(null,![],{'message':_0x0b00('0x1b')});}else{return utils['getLicense'](_0x4a4d4c)['then'](function(){return _0x58472e(null,_0x4a4d4c);});}}}});})[_0x0b00('0x1e')](function(_0x3e9166){return _0x58472e(null,![],_0x3e9166);});}function sendServiceMail(_0x335bf2){return db[_0x0b00('0x1f')][_0x0b00('0x20')]({'where':{'service':!![]},'attributes':['id',_0x0b00('0xf'),_0x0b00('0x21')],'include':[{'model':db[_0x0b00('0x22')],'as':_0x0b00('0x23'),'include':[{'model':db[_0x0b00('0x24')],'as':_0x0b00('0x24')}]}]})[_0x0b00('0xe')](function(_0x59f702){if(!_0x59f702){throw new Error(_0x0b00('0x25'));}var _0xcd148b=_0x59f702['getSmtpOptions']();var _0x1beca7={'account':_0xcd148b,'message':_[_0x0b00('0x26')]({'from':util[_0x0b00('0x27')](_0x0b00('0x28'),_0x59f702[_0x0b00('0xf')],_0x59f702[_0x0b00('0x21')]||_0x59f702[_0x0b00('0x23')]['user'])},_0x335bf2)};return client['request'](_0x0b00('0x29'),_0x1beca7);})[_0x0b00('0xe')](function(_0x15cf61){if(_0x15cf61[_0x0b00('0x2a')]){throw new Error(util[_0x0b00('0x27')]('SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!',_0x15cf61[_0x0b00('0x2a')][_0x0b00('0x2b')]||JSON[_0x0b00('0x2c')](_0x15cf61[_0x0b00('0x2a')])));}return!![];});}function handleError(_0x1b0863,_0x56351d,_0x1acdd1){return _0x1b0863[_0x0b00('0x2d')](_0x56351d||0x1f4)['send']({'message':_0x1acdd1?_0x1acdd1[_0x0b00('0x2b')]||_0x1acdd1:''});}exports[_0x0b00('0x2e')]=function(_0x57eca7,_0x4d4fe5,_0x564991){passport['authenticate'](_0x0b00('0x2f'),function(_0x136a57,_0x486552,_0x265e7a){var _0x27c997=_0x136a57||_0x265e7a;if(_0x27c997){return handleError(_0x4d4fe5,0x191,_0x27c997);}if(!_0x486552){return handleError(_0x4d4fe5,0x194,{'message':_0x0b00('0x30')});}else{var _0x451b03={'payload':{'id':_0x486552['id'],'role':_0x486552[_0x0b00('0x12')]},'options':{'expiresIn':0x15180}};return authService[_0x0b00('0x31')](_0x451b03)[_0x0b00('0xe')](function(_0x23334d){_0x4d4fe5[_0x0b00('0x32')]({'id':_0x486552['id'],'token':_0x23334d,'statusCall':'','isAlreadyLogged':_0x486552[_0x0b00('0x33')]});});}})(_0x57eca7,_0x4d4fe5,_0x564991);};exports[_0x0b00('0x34')]=function(_0x32a107,_0x5966d6){if(!_0x32a107[_0x0b00('0x35')][_0x0b00('0x21')]){return handleError(_0x5966d6,0x1f4,{'message':_0x0b00('0x36')});}var _0xccf004=rs[_0x0b00('0x37')]();_0x32a107['body']['email']=_0x32a107[_0x0b00('0x35')][_0x0b00('0x21')][_0x0b00('0x38')]()[_0x0b00('0x39')]();var _0x4d4e7d;return db[_0x0b00('0xa')][_0x0b00('0xb')]({'where':{'id':0x1},'attributes':[_0x0b00('0xc'),_0x0b00('0xd')],'raw':!![]})[_0x0b00('0xe')](function(_0x396845){_0x4d4e7d=_0x396845;return db['User'][_0x0b00('0x20')]({'where':{'email':_0x32a107['body'][_0x0b00('0x21')]}});})['then'](function(_0x2aede6){if(!_0x2aede6){throw new Error(_0x0b00('0x3a'));}if(_0x2aede6[_0x0b00('0x13')]){throw new Error('The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.');}if(_0x2aede6[_0x0b00('0x18')]){if(moment(_0x2aede6['blockedAt'])[_0x0b00('0x19')](_0x4d4e7d['blockDuration'],_0x0b00('0x1a'))>moment()){throw new Error(_0x0b00('0x3b'));}else{_0x2aede6[_0x0b00('0x18')]=![];_0x2aede6['blockedAt']=null;}}_0x2aede6[_0x0b00('0x3c')]=_0xccf004;_0x2aede6[_0x0b00('0x3d')]=Date[_0x0b00('0x3e')]()+0x36ee80;return _0x2aede6[_0x0b00('0x3f')]();})[_0x0b00('0xe')](function(){return sendServiceMail({'to':_0x32a107[_0x0b00('0x35')][_0x0b00('0x21')],'subject':'xCally\x20Motion\x20Password\x20Reset','text':'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'+_0x0b00('0x40')+_0x32a107[_0x0b00('0x41')]['host']+_0x0b00('0x42')+_0xccf004+'\x0a\x0a'+_0x0b00('0x43')});})[_0x0b00('0xe')](function(){_0x5966d6[_0x0b00('0x2d')](0xc8)[_0x0b00('0x44')]({'message':'Reset\x20Email\x20sent!'});})[_0x0b00('0x1e')](function(_0x326f5f){return handleError(_0x5966d6,0x1f4,_0x326f5f);});};exports['reset']=function(_0x2251c6,_0x549ed6){return db['User']['find']({'where':{'resetPasswordToken':_0x2251c6[_0x0b00('0x45')][_0x0b00('0x46')],'resetPasswordExpires':{'$gt':Date[_0x0b00('0x3e')]()}}})[_0x0b00('0xe')](function(_0x2b3a94){if(!_0x2b3a94){throw new Error('Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.');}return db[_0x0b00('0xa')][_0x0b00('0xb')]({'attributes':['id',_0x0b00('0x47'),_0x0b00('0x48'),_0x0b00('0x49')]})[_0x0b00('0xe')](function(_0x19e0a4){if(_0x19e0a4[_0x0b00('0x47')])authService[_0x0b00('0x4a')](_0x2251c6[_0x0b00('0x35')][_0x0b00('0x10')]);if(!_0x19e0a4[_0x0b00('0x48')]||!_0x2b3a94[_0x0b00('0x4b')])return _0x2b3a94;authService[_0x0b00('0x4c')](_0x2251c6[_0x0b00('0x35')][_0x0b00('0x10')],_0x2b3a94['previousPasswords'],_0x19e0a4['passwordHistoryLimit']);return _0x2b3a94;})[_0x0b00('0xe')](function(){_0x2b3a94[_0x0b00('0x10')]=_0x2251c6[_0x0b00('0x35')]['password'];_0x2b3a94[_0x0b00('0x3c')]=null;_0x2b3a94['resetPasswordExpires']=null;return _0x2b3a94['save']();});})[_0x0b00('0xe')](function(){_0x549ed6[_0x0b00('0x2d')](0xc8)['send']({'message':'Password\x20reset!'});})[_0x0b00('0x1e')](function(_0x15ea94){return handleError(_0x549ed6,0x1f4,_0x15ea94);});};passport[_0x0b00('0x4d')](_0x0b00('0x2f'),new LocalStrategy({'usernameField':_0x0b00('0xf'),'passwordField':_0x0b00('0x10')},function(_0x279bc7,_0x157bc2,_0x331b53){return localAuthenticate(db[_0x0b00('0x4e')],_0x279bc7,_0x157bc2,_0x331b53);}));
\ No newline at end of file
+var _0x9795=['MailAccount','email','MailServerOut','Smtp','CloudProvider','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','getSmtpOptions','format','\x22%s\x22\x20<%s>','user','request','SendMail','error','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','stringify','status','send','message','login','json','online','forgot','Email\x20parameter\x20is\x20missing','generate','body','toLowerCase','User','find','This\x20email\x20is\x20not\x20registered.','The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.','minutes','resetPasswordToken','resetPasswordExpires','save','You\x20are\x20receiving\x20this\x20because\x20you\x20(or\x20someone\x20else)\x20have\x20requested\x20the\x20reset\x20of\x20the\x20password\x20for\x20your\x20account.\x0a\x0a','headers','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','reset','params','token','now','securePassword','enforcePasswordHistory','passwordHistoryLimit','use','local-login','util','passport','passport-local','Strategy','jayson/promise','randomstring','../../components/auth/service','client','Setting','findOne','blockDuration','name','password','salt','role','disabled','blocked','blockedAt','loginAttempts','agent','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','then','authenticate','allowedLoginAttempts','add','clearBlockUser','catch'];(function(_0x2331f4,_0xe518c3){var _0x224d15=function(_0xa917c5){while(--_0xa917c5){_0x2331f4['push'](_0x2331f4['shift']());}};_0x224d15(++_0xe518c3);}(_0x9795,0x157));var _0x5979=function(_0x46344e,_0x516028){_0x46344e=_0x46344e-0x0;var _0x42a4f5=_0x9795[_0x46344e];return _0x42a4f5;};'use strict';var util=require(_0x5979('0x0'));var passport=require(_0x5979('0x1'));var LocalStrategy=require(_0x5979('0x2'))[_0x5979('0x3')];var jayson=require(_0x5979('0x4'));var _=require('lodash');var rs=require(_0x5979('0x5'));var moment=require('moment');var db=require('../../mysqldb')['db'];var authService=require(_0x5979('0x6'));var utils=require('../../config/utils');var client=jayson[_0x5979('0x7')]['http']({'port':0x232b});function localAuthenticate(_0x2d74c9,_0xabd45a,_0x505829,_0x33b227){var _0x2bb3cd,_0x341f98;return db[_0x5979('0x8')][_0x5979('0x9')]({'where':{'id':0x1},'attributes':['allowedLoginAttempts',_0x5979('0xa')],'raw':!![]})['then'](function(_0x5d389e){_0x2bb3cd=_0x5d389e;return _0x2d74c9['findOne']({'attributes':['id',_0x5979('0xb'),_0x5979('0xc'),_0x5979('0xd'),_0x5979('0xe'),_0x5979('0xf'),_0x5979('0x10'),_0x5979('0x11'),_0x5979('0x12')],'where':{'name':_0xabd45a,'role':{'$or':['admin','user',_0x5979('0x13')]}}});})['then'](function(_0x15497e){if(!_0x15497e||_0x15497e&&_0x15497e['name']!==_0xabd45a){throw new Error(_0x5979('0x14'));}else{_0x341f98=_0x15497e;return _0x341f98;}})[_0x5979('0x15')](function(){_0x341f98[_0x5979('0x16')](_0x505829,function(_0x466f73,_0x6243ed){var _0x41275b=_0x341f98[_0x5979('0x12')]+0x1;if(_0x466f73){return _0x33b227(_0x466f73);}else if(!_0x6243ed){if(_0x341f98[_0x5979('0xf')]){return _0x33b227(null,![],{'message':_0x5979('0x14')});}else if(_0x2bb3cd['allowedLoginAttempts']>0x0){if(_0x341f98[_0x5979('0x10')]){if(_0x2bb3cd[_0x5979('0xa')]>0x0){if(moment(_0x341f98[_0x5979('0x11')])['add'](_0x2bb3cd[_0x5979('0xa')],'minutes')>moment()){return _0x33b227(null,![],{'message':_0x5979('0x14')});}else{return utils['clearBlockUser'](_0x341f98,_0x41275b,![],null)[_0x5979('0x15')](function(){return _0x33b227(null,![],{'message':_0x5979('0x14')});});}}else{return _0x33b227(null,![],{'message':_0x5979('0x14')});}}else{if(_0x41275b>=_0x2bb3cd[_0x5979('0x17')]){return utils['clearBlockUser'](_0x341f98,0x0,!![],moment())[_0x5979('0x15')](function(){return _0x33b227(null,![],{'message':_0x5979('0x14')});});}else{return utils['clearBlockUser'](_0x341f98,_0x41275b,![],null)[_0x5979('0x15')](function(){return _0x33b227(null,![],{'message':_0x5979('0x14')});});}}}else{return _0x33b227(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{if(_0x341f98['disabled']){return _0x33b227(null,![],{'message':_0x5979('0x14')});}else if(_0x2bb3cd[_0x5979('0x17')]>0x0){if(_0x341f98['blocked']){if(_0x2bb3cd[_0x5979('0xa')]>0x0){if(moment(_0x341f98[_0x5979('0x11')])[_0x5979('0x18')](_0x2bb3cd['blockDuration'],'minutes')>moment()){return _0x33b227(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils[_0x5979('0x19')](_0x341f98,0x0,![],null)['then'](function(){return utils['getLicense'](_0x341f98);})[_0x5979('0x15')](function(){return _0x33b227(null,_0x341f98);});}}else{return _0x33b227(null,![],{'message':_0x5979('0x14')});}}else{return utils[_0x5979('0x19')](_0x341f98,0x0,![],null)[_0x5979('0x15')](function(){return utils['getLicense'](_0x341f98);})[_0x5979('0x15')](function(){return _0x33b227(null,_0x341f98);})[_0x5979('0x1a')](function(_0x514b51){return _0x33b227(null,![],_0x514b51);});}}else{if(_0x341f98[_0x5979('0x10')]){return _0x33b227(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils['getLicense'](_0x341f98)[_0x5979('0x15')](function(){return _0x33b227(null,_0x341f98);});}}}});})['catch'](function(_0x1478b7){return _0x33b227(null,![],_0x1478b7);});}function sendServiceMail(_0x5c0d5f){return db[_0x5979('0x1b')]['find']({'where':{'service':!![]},'attributes':['id',_0x5979('0xb'),_0x5979('0x1c')],'include':[{'model':db[_0x5979('0x1d')],'as':_0x5979('0x1e'),'include':[{'model':db[_0x5979('0x1f')],'as':_0x5979('0x1f')}]}]})[_0x5979('0x15')](function(_0x9b3932){if(!_0x9b3932){throw new Error(_0x5979('0x20'));}var _0x1adf1a=_0x9b3932[_0x5979('0x21')]();var _0x30421e={'account':_0x1adf1a,'message':_['merge']({'from':util[_0x5979('0x22')](_0x5979('0x23'),_0x9b3932[_0x5979('0xb')],_0x9b3932[_0x5979('0x1c')]||_0x9b3932[_0x5979('0x1e')][_0x5979('0x24')])},_0x5c0d5f)};return client[_0x5979('0x25')](_0x5979('0x26'),_0x30421e);})['then'](function(_0x3e06c0){if(_0x3e06c0[_0x5979('0x27')]){throw new Error(util[_0x5979('0x22')](_0x5979('0x28'),_0x3e06c0[_0x5979('0x27')]['message']||JSON[_0x5979('0x29')](_0x3e06c0[_0x5979('0x27')])));}return!![];});}function handleError(_0x4539b7,_0x449259,_0x3b9958){return _0x4539b7[_0x5979('0x2a')](_0x449259||0x1f4)[_0x5979('0x2b')]({'message':_0x3b9958?_0x3b9958[_0x5979('0x2c')]||_0x3b9958:''});}exports[_0x5979('0x2d')]=function(_0x539525,_0x42b317,_0x560fa3){passport[_0x5979('0x16')]('local-login',function(_0x452ba7,_0x1a9497,_0x24f00b){var _0x5c7203=_0x452ba7||_0x24f00b;if(_0x5c7203){return handleError(_0x42b317,0x191,_0x5c7203);}if(!_0x1a9497){return handleError(_0x42b317,0x194,{'message':'Something\x20went\x20wrong,\x20please\x20try\x20again.'});}else{var _0x4443ac={'payload':{'id':_0x1a9497['id'],'role':_0x1a9497[_0x5979('0xe')]},'options':{'expiresIn':0x15180}};return authService['signToken'](_0x4443ac)[_0x5979('0x15')](function(_0x2935b6){_0x42b317[_0x5979('0x2e')]({'id':_0x1a9497['id'],'token':_0x2935b6,'statusCall':'','isAlreadyLogged':_0x1a9497[_0x5979('0x2f')]});});}})(_0x539525,_0x42b317,_0x560fa3);};exports[_0x5979('0x30')]=function(_0x36d130,_0x23e1d0){if(!_0x36d130['body']['email']){return handleError(_0x23e1d0,0x1f4,{'message':_0x5979('0x31')});}var _0xc72589=rs[_0x5979('0x32')]();_0x36d130['body']['email']=_0x36d130[_0x5979('0x33')][_0x5979('0x1c')]['trim']()[_0x5979('0x34')]();var _0x1eb186;return db[_0x5979('0x8')][_0x5979('0x9')]({'where':{'id':0x1},'attributes':[_0x5979('0x17'),_0x5979('0xa')],'raw':!![]})[_0x5979('0x15')](function(_0x8838b1){_0x1eb186=_0x8838b1;return db[_0x5979('0x35')][_0x5979('0x36')]({'where':{'email':_0x36d130[_0x5979('0x33')][_0x5979('0x1c')]}});})['then'](function(_0x54106f){if(!_0x54106f){throw new Error(_0x5979('0x37'));}if(_0x54106f[_0x5979('0xf')]){throw new Error(_0x5979('0x38'));}if(_0x54106f[_0x5979('0x10')]){if(moment(_0x54106f['blockedAt'])[_0x5979('0x18')](_0x1eb186['blockDuration'],_0x5979('0x39'))>moment()){throw new Error('The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.');}else{_0x54106f['blocked']=![];_0x54106f['blockedAt']=null;}}_0x54106f[_0x5979('0x3a')]=_0xc72589;_0x54106f[_0x5979('0x3b')]=Date['now']()+0x36ee80;return _0x54106f[_0x5979('0x3c')]();})[_0x5979('0x15')](function(){return sendServiceMail({'to':_0x36d130[_0x5979('0x33')]['email'],'subject':'xCally\x20Motion\x20Password\x20Reset','text':_0x5979('0x3d')+'Please\x20click\x20on\x20the\x20following\x20link,\x20or\x20paste\x20this\x20into\x20your\x20browser\x20to\x20complete\x20the\x20process:\x0a\x0a'+'https://'+_0x36d130[_0x5979('0x3e')]['host']+_0x5979('0x3f')+_0xc72589+'\x0a\x0a'+_0x5979('0x40')});})[_0x5979('0x15')](function(){_0x23e1d0['status'](0xc8)[_0x5979('0x2b')]({'message':'Reset\x20Email\x20sent!'});})[_0x5979('0x1a')](function(_0x314691){return handleError(_0x23e1d0,0x1f4,_0x314691);});};exports[_0x5979('0x41')]=function(_0x46a5be,_0x532883){return db[_0x5979('0x35')][_0x5979('0x36')]({'where':{'resetPasswordToken':_0x46a5be[_0x5979('0x42')][_0x5979('0x43')],'resetPasswordExpires':{'$gt':Date[_0x5979('0x44')]()}}})[_0x5979('0x15')](function(_0x27ea76){if(!_0x27ea76){throw new Error('Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.');}return db['Setting'][_0x5979('0x9')]({'attributes':['id',_0x5979('0x45'),_0x5979('0x46'),_0x5979('0x47')]})['then'](function(_0x571d44){if(_0x571d44[_0x5979('0x45')])authService['validatePasswordPattern'](_0x46a5be[_0x5979('0x33')][_0x5979('0xc')]);if(!_0x571d44['enforcePasswordHistory']||!_0x27ea76['previousPasswords'])return _0x27ea76;authService['validatePasswordHistory'](_0x46a5be[_0x5979('0x33')][_0x5979('0xc')],_0x27ea76['previousPasswords'],_0x571d44[_0x5979('0x47')]);return _0x27ea76;})[_0x5979('0x15')](function(){_0x27ea76[_0x5979('0xc')]=_0x46a5be[_0x5979('0x33')]['password'];_0x27ea76[_0x5979('0x3a')]=null;_0x27ea76[_0x5979('0x3b')]=null;return _0x27ea76[_0x5979('0x3c')]();});})[_0x5979('0x15')](function(){_0x532883[_0x5979('0x2a')](0xc8)[_0x5979('0x2b')]({'message':'Password\x20reset!'});})[_0x5979('0x1a')](function(_0x5ef745){return handleError(_0x532883,0x1f4,_0x5ef745);});};passport[_0x5979('0x48')](_0x5979('0x49'),new LocalStrategy({'usernameField':_0x5979('0xb'),'passwordField':_0x5979('0xc')},function(_0x324610,_0x8649c4,_0x4edec4){return localAuthenticate(db[_0x5979('0x35')],_0x324610,_0x8649c4,_0x4edec4);}));
\ No newline at end of file