Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / authLocal / authLocal.controller.js
index f117376..6d9e6a3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2b55=['password','salt','role','disabled','loginAttempts','admin','user','agent','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','blockDuration','blockedAt','clearBlockUser','blocked','add','minutes','getLicense','catch','find','email','Smtp','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','service','host','port','secure','authentication','auth','pass','format','request','SendMail','error','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','message','stringify','send','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','signToken','online','forgot','body','Email\x20parameter\x20is\x20missing','generate','User','This\x20email\x20is\x20not\x20registered.','The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.','The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.','resetPasswordExpires','save','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','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','status','Reset\x20Email\x20sent!','reset','params','token','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','Password\x20reset!','use','util','passport','passport-local','Strategy','jayson/promise','lodash','randomstring','../../components/auth/service','../../config/utils','client','http','Setting','findOne','allowedLoginAttempts','then','name'];(function(_0x32034d,_0x3cd7a9){var _0xe6a87d=function(_0xb9262c){while(--_0xb9262c){_0x32034d['push'](_0x32034d['shift']());}};_0xe6a87d(++_0x3cd7a9);}(_0x2b55,0x180));var _0x52b5=function(_0x27ee9f,_0x4e179e){_0x27ee9f=_0x27ee9f-0x0;var _0x2b9066=_0x2b55[_0x27ee9f];return _0x2b9066;};'use strict';var util=require(_0x52b5('0x0'));var passport=require(_0x52b5('0x1'));var LocalStrategy=require(_0x52b5('0x2'))[_0x52b5('0x3')];var jayson=require(_0x52b5('0x4'));var _=require(_0x52b5('0x5'));var rs=require(_0x52b5('0x6'));var moment=require('moment');var db=require('../../mysqldb')['db'];var authService=require(_0x52b5('0x7'));var utils=require(_0x52b5('0x8'));var client=jayson[_0x52b5('0x9')][_0x52b5('0xa')]({'port':0x232b});function localAuthenticate(_0x3582ad,_0x1c1ea2,_0x2bf6ad,_0x2af60a){var _0x4a0c79,_0x5548eb;return db[_0x52b5('0xb')][_0x52b5('0xc')]({'where':{'id':0x1},'attributes':[_0x52b5('0xd'),'blockDuration'],'raw':!![]})[_0x52b5('0xe')](function(_0x22b926){_0x4a0c79=_0x22b926;return _0x3582ad[_0x52b5('0xc')]({'attributes':['id',_0x52b5('0xf'),_0x52b5('0x10'),_0x52b5('0x11'),_0x52b5('0x12'),_0x52b5('0x13'),'blocked','blockedAt',_0x52b5('0x14')],'where':{'name':_0x1c1ea2,'role':{'$or':[_0x52b5('0x15'),_0x52b5('0x16'),_0x52b5('0x17')]}}});})[_0x52b5('0xe')](function(_0x46fa25){if(!_0x46fa25||_0x46fa25&&_0x46fa25[_0x52b5('0xf')]!==_0x1c1ea2){throw new Error(_0x52b5('0x18'));}else{_0x5548eb=_0x46fa25;return _0x5548eb;}})[_0x52b5('0xe')](function(){_0x5548eb['authenticate'](_0x2bf6ad,function(_0x1e43c5,_0xf3dfdf){var _0x29afb5=_0x5548eb[_0x52b5('0x14')]+0x1;if(_0x1e43c5){return _0x2af60a(_0x1e43c5);}else if(!_0xf3dfdf){if(_0x5548eb[_0x52b5('0x13')]){return _0x2af60a(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else if(_0x4a0c79['allowedLoginAttempts']>0x0){if(_0x5548eb['blocked']){if(_0x4a0c79[_0x52b5('0x19')]>0x0){if(moment(_0x5548eb[_0x52b5('0x1a')])['add'](_0x4a0c79[_0x52b5('0x19')],'minutes')>moment()){return _0x2af60a(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils['clearBlockUser'](_0x5548eb,_0x29afb5,![],null)[_0x52b5('0xe')](function(){return _0x2af60a(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}}else{return _0x2af60a(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{if(_0x29afb5>=_0x4a0c79[_0x52b5('0xd')]){return utils['clearBlockUser'](_0x5548eb,0x0,!![],moment())['then'](function(){return _0x2af60a(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}else{return utils[_0x52b5('0x1b')](_0x5548eb,_0x29afb5,![],null)['then'](function(){return _0x2af60a(null,![],{'message':_0x52b5('0x18')});});}}}else{return _0x2af60a(null,![],{'message':_0x52b5('0x18')});}}else{if(_0x5548eb[_0x52b5('0x13')]){return _0x2af60a(null,![],{'message':_0x52b5('0x18')});}else if(_0x4a0c79[_0x52b5('0xd')]>0x0){if(_0x5548eb[_0x52b5('0x1c')]){if(_0x4a0c79['blockDuration']>0x0){if(moment(_0x5548eb['blockedAt'])[_0x52b5('0x1d')](_0x4a0c79[_0x52b5('0x19')],_0x52b5('0x1e'))>moment()){return _0x2af60a(null,![],{'message':_0x52b5('0x18')});}else{return utils[_0x52b5('0x1b')](_0x5548eb,0x0,![],null)[_0x52b5('0xe')](function(){return utils[_0x52b5('0x1f')](_0x5548eb);})[_0x52b5('0xe')](function(){return _0x2af60a(null,_0x5548eb);});}}else{return _0x2af60a(null,![],{'message':_0x52b5('0x18')});}}else{return utils['clearBlockUser'](_0x5548eb,0x0,![],null)['then'](function(){return utils[_0x52b5('0x1f')](_0x5548eb);})[_0x52b5('0xe')](function(){return _0x2af60a(null,_0x5548eb);})['catch'](function(_0x40fd99){return _0x2af60a(null,![],_0x40fd99);});}}else{if(_0x5548eb[_0x52b5('0x1c')]){return _0x2af60a(null,![],{'message':_0x52b5('0x18')});}else{return utils[_0x52b5('0x1f')](_0x5548eb)[_0x52b5('0xe')](function(){return _0x2af60a(null,_0x5548eb);});}}}});})[_0x52b5('0x20')](function(_0x227d8e){return _0x2af60a(null,![],_0x227d8e);});}function sendServiceMail(_0x4c4ccf){return db['MailAccount'][_0x52b5('0x21')]({'where':{'service':!![]},'attributes':['id',_0x52b5('0xf'),_0x52b5('0x22')],'include':[{'model':db['MailServerOut'],'as':_0x52b5('0x23')}]})['then'](function(_0x345f94){if(!_0x345f94){throw new Error(_0x52b5('0x24'));}var _0x3cd5bd={'tls':{'rejectUnauthorized':![]}};if(_0x345f94['Smtp'][_0x52b5('0x25')]){_0x3cd5bd[_0x52b5('0x25')]=_0x345f94[_0x52b5('0x23')][_0x52b5('0x25')];}else{_0x3cd5bd[_0x52b5('0x26')]=_0x345f94[_0x52b5('0x23')][_0x52b5('0x26')];_0x3cd5bd[_0x52b5('0x27')]=_0x345f94['Smtp'][_0x52b5('0x27')];_0x3cd5bd[_0x52b5('0x28')]=_0x345f94[_0x52b5('0x23')][_0x52b5('0x28')];}if(_0x345f94[_0x52b5('0x23')][_0x52b5('0x29')]){_0x3cd5bd[_0x52b5('0x2a')]={'user':_0x345f94[_0x52b5('0x23')][_0x52b5('0x16')],'pass':_0x345f94[_0x52b5('0x23')][_0x52b5('0x2b')]};}var _0xedb170={'account':_0x3cd5bd,'message':_['merge']({'from':util[_0x52b5('0x2c')]('\x22%s\x22\x20<%s>',_0x345f94['name'],_0x345f94['email']||_0x345f94[_0x52b5('0x23')][_0x52b5('0x16')])},_0x4c4ccf)};return client[_0x52b5('0x2d')](_0x52b5('0x2e'),_0xedb170);})['then'](function(_0x245a93){if(_0x245a93[_0x52b5('0x2f')]){throw new Error(util[_0x52b5('0x2c')](_0x52b5('0x30'),_0x245a93['error'][_0x52b5('0x31')]||JSON[_0x52b5('0x32')](_0x245a93[_0x52b5('0x2f')])));}return!![];});}function handleError(_0x2c0d35,_0x186154,_0x4bc0dd){return _0x2c0d35['status'](_0x186154||0x1f4)[_0x52b5('0x33')]({'message':_0x4bc0dd?_0x4bc0dd[_0x52b5('0x31')]||_0x4bc0dd:''});}function checkPasswordPattern(_0x39da26,_0x1bcf2a,_0x2865c1){if(_0x2865c1){var _0x172cb2=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x172cb2[_0x52b5('0x34')](_0x1bcf2a)){return _0x39da26;}else{throw new Error(_0x52b5('0x35'));}}else{return _0x39da26;}}exports[_0x52b5('0x36')]=function(_0x64a110,_0x2473b2,_0x2ced2b){passport['authenticate']('local',function(_0x5c7d1b,_0x4e7b2d,_0x1cf3ab){var _0xbc167=_0x5c7d1b||_0x1cf3ab;if(_0xbc167){return handleError(_0x2473b2,0x191,_0xbc167);}if(!_0x4e7b2d){return handleError(_0x2473b2,0x194,{'message':'Something\x20went\x20wrong,\x20please\x20try\x20again.'});}else{var _0x36df80={'payload':{'id':_0x4e7b2d['id'],'role':_0x4e7b2d['role']},'options':{'expiresIn':0x15180}};return authService[_0x52b5('0x37')](_0x36df80)[_0x52b5('0xe')](function(_0x40050a){_0x2473b2['json']({'id':_0x4e7b2d['id'],'token':_0x40050a,'statusCall':'','isAlreadyLogged':_0x4e7b2d[_0x52b5('0x38')]});});}})(_0x64a110,_0x2473b2,_0x2ced2b);};exports[_0x52b5('0x39')]=function(_0x478710,_0x41392f,_0x4d71b7){if(!_0x478710[_0x52b5('0x3a')]['email']){return handleError(_0x41392f,0x1f4,{'message':_0x52b5('0x3b')});}var _0x32e2a6=rs[_0x52b5('0x3c')]();_0x478710['body'][_0x52b5('0x22')]=_0x478710[_0x52b5('0x3a')]['email']['trim']()['toLowerCase']();var _0x2db94e;return db['Setting'][_0x52b5('0xc')]({'where':{'id':0x1},'attributes':[_0x52b5('0xd'),_0x52b5('0x19')],'raw':!![]})[_0x52b5('0xe')](function(_0xab33a1){_0x2db94e=_0xab33a1;return db[_0x52b5('0x3d')][_0x52b5('0x21')]({'where':{'email':_0x478710[_0x52b5('0x3a')][_0x52b5('0x22')]}});})[_0x52b5('0xe')](function(_0x52cc04){if(!_0x52cc04){throw new Error(_0x52b5('0x3e'));}if(_0x52cc04[_0x52b5('0x13')]){throw new Error(_0x52b5('0x3f'));}if(_0x52cc04[_0x52b5('0x1c')]){if(moment(_0x52cc04[_0x52b5('0x1a')])['add'](_0x2db94e['blockDuration'],_0x52b5('0x1e'))>moment()){throw new Error(_0x52b5('0x40'));}else{_0x52cc04['blocked']=![];_0x52cc04[_0x52b5('0x1a')]=null;}}_0x52cc04['resetPasswordToken']=_0x32e2a6;_0x52cc04[_0x52b5('0x41')]=Date['now']()+0x36ee80;return _0x52cc04[_0x52b5('0x42')]();})[_0x52b5('0xe')](function(){return sendServiceMail({'to':_0x478710['body'][_0x52b5('0x22')],'subject':'xCally\x20Motion\x20Password\x20Reset','text':_0x52b5('0x43')+_0x52b5('0x44')+'http://'+_0x478710[_0x52b5('0x45')][_0x52b5('0x26')]+_0x52b5('0x46')+_0x32e2a6+'\x0a\x0a'+_0x52b5('0x47')});})[_0x52b5('0xe')](function(){_0x41392f[_0x52b5('0x48')](0xc8)[_0x52b5('0x33')]({'message':_0x52b5('0x49')});})[_0x52b5('0x20')](function(_0x56c9ff){return handleError(_0x41392f,0x1f4,_0x56c9ff);});};exports[_0x52b5('0x4a')]=function(_0x309199,_0x2d6e67,_0x35f558){var _0x22e928;return db[_0x52b5('0x3d')][_0x52b5('0x21')]({'where':{'resetPasswordToken':_0x309199[_0x52b5('0x4b')][_0x52b5('0x4c')],'resetPasswordExpires':{'$gt':Date['now']()}}})['then'](function(_0x412e58){_0x22e928=_0x412e58;if(!_0x22e928){throw new Error(_0x52b5('0x4d'));}return db[_0x52b5('0xb')][_0x52b5('0xc')]({'attributes':['id','securePassword']});})[_0x52b5('0xe')](function(_0xbcffd6){return checkPasswordPattern(_0xbcffd6,_0x309199[_0x52b5('0x3a')]['password'],_0xbcffd6['securePassword']);})[_0x52b5('0xe')](function(){_0x22e928['password']=_0x309199[_0x52b5('0x3a')][_0x52b5('0x10')];_0x22e928['resetPasswordToken']=null;_0x22e928[_0x52b5('0x41')]=null;return _0x22e928[_0x52b5('0x42')]();})['then'](function(){_0x2d6e67[_0x52b5('0x48')](0xc8)[_0x52b5('0x33')]({'message':_0x52b5('0x4e')});})[_0x52b5('0x20')](function(_0x259401){return handleError(_0x2d6e67,0x1f4,_0x259401);});};passport[_0x52b5('0x4f')](new LocalStrategy({'usernameField':'name','passwordField':'password'},function(_0x1939c5,_0x56b5a5,_0x3fb565){return localAuthenticate(db['User'],_0x1939c5,_0x56b5a5,_0x3fb565);}));
\ No newline at end of file
+var _0xb4c7=['json','online','Email\x20parameter\x20is\x20missing','generate','body','email','trim','User','find','This\x20email\x20is\x20not\x20registered.','resetPasswordToken','resetPasswordExpires','save','Please\x20click\x20on\x20the\x20following\x20link,\x20or\x20paste\x20this\x20into\x20your\x20browser\x20to\x20complete\x20the\x20process:\x0a\x0a','http://','headers','/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.','securePassword','Password\x20reset!','use','util','passport','passport-local','../../mysqldb','../../config/utils','client','http','Setting','findOne','allowedLoginAttempts','blockDuration','name','password','blockedAt','loginAttempts','user','agent','then','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','disabled','add','clearBlockUser','minutes','getLicense','catch','blocked','MailAccount','MailServerOut','Smtp','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','service','host','port','secure','authentication','auth','pass','merge','\x22%s\x22\x20<%s>','SendMail','error','format','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','stringify','status','message','test','authenticate','local','Something\x20went\x20wrong,\x20please\x20try\x20again.'];(function(_0x188cc8,_0xd39746){var _0x4cb155=function(_0x2d2a6c){while(--_0x2d2a6c){_0x188cc8['push'](_0x188cc8['shift']());}};_0x4cb155(++_0xd39746);}(_0xb4c7,0x19c));var _0x7b4c=function(_0x6939e9,_0x1ea346){_0x6939e9=_0x6939e9-0x0;var _0x32f2dc=_0xb4c7[_0x6939e9];return _0x32f2dc;};'use strict';var util=require(_0x7b4c('0x0'));var passport=require(_0x7b4c('0x1'));var LocalStrategy=require(_0x7b4c('0x2'))['Strategy'];var jayson=require('jayson/promise');var _=require('lodash');var rs=require('randomstring');var moment=require('moment');var db=require(_0x7b4c('0x3'))['db'];var authService=require('../../components/auth/service');var utils=require(_0x7b4c('0x4'));var client=jayson[_0x7b4c('0x5')][_0x7b4c('0x6')]({'port':0x232b});function localAuthenticate(_0x23ef23,_0x45631a,_0x390317,_0x5905c8){var _0x236939,_0x390d28;return db[_0x7b4c('0x7')][_0x7b4c('0x8')]({'where':{'id':0x1},'attributes':[_0x7b4c('0x9'),_0x7b4c('0xa')],'raw':!![]})['then'](function(_0x1660a7){_0x236939=_0x1660a7;return _0x23ef23[_0x7b4c('0x8')]({'attributes':['id',_0x7b4c('0xb'),_0x7b4c('0xc'),'salt','role','disabled','blocked',_0x7b4c('0xd'),_0x7b4c('0xe')],'where':{'name':_0x45631a,'role':{'$or':['admin',_0x7b4c('0xf'),_0x7b4c('0x10')]}}});})[_0x7b4c('0x11')](function(_0x24ba8c){if(!_0x24ba8c||_0x24ba8c&&_0x24ba8c[_0x7b4c('0xb')]!==_0x45631a){throw new Error(_0x7b4c('0x12'));}else{_0x390d28=_0x24ba8c;return _0x390d28;}})[_0x7b4c('0x11')](function(){_0x390d28['authenticate'](_0x390317,function(_0x2061c3,_0x411f28){var _0x2ed4a9=_0x390d28[_0x7b4c('0xe')]+0x1;if(_0x2061c3){return _0x5905c8(_0x2061c3);}else if(!_0x411f28){if(_0x390d28[_0x7b4c('0x13')]){return _0x5905c8(null,![],{'message':_0x7b4c('0x12')});}else if(_0x236939['allowedLoginAttempts']>0x0){if(_0x390d28['blocked']){if(_0x236939[_0x7b4c('0xa')]>0x0){if(moment(_0x390d28[_0x7b4c('0xd')])[_0x7b4c('0x14')](_0x236939[_0x7b4c('0xa')],'minutes')>moment()){return _0x5905c8(null,![],{'message':_0x7b4c('0x12')});}else{return utils[_0x7b4c('0x15')](_0x390d28,_0x2ed4a9,![],null)[_0x7b4c('0x11')](function(){return _0x5905c8(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}}else{return _0x5905c8(null,![],{'message':_0x7b4c('0x12')});}}else{if(_0x2ed4a9>=_0x236939[_0x7b4c('0x9')]){return utils[_0x7b4c('0x15')](_0x390d28,0x0,!![],moment())['then'](function(){return _0x5905c8(null,![],{'message':_0x7b4c('0x12')});});}else{return utils[_0x7b4c('0x15')](_0x390d28,_0x2ed4a9,![],null)[_0x7b4c('0x11')](function(){return _0x5905c8(null,![],{'message':_0x7b4c('0x12')});});}}}else{return _0x5905c8(null,![],{'message':_0x7b4c('0x12')});}}else{if(_0x390d28[_0x7b4c('0x13')]){return _0x5905c8(null,![],{'message':_0x7b4c('0x12')});}else if(_0x236939['allowedLoginAttempts']>0x0){if(_0x390d28['blocked']){if(_0x236939[_0x7b4c('0xa')]>0x0){if(moment(_0x390d28[_0x7b4c('0xd')])[_0x7b4c('0x14')](_0x236939['blockDuration'],_0x7b4c('0x16'))>moment()){return _0x5905c8(null,![],{'message':_0x7b4c('0x12')});}else{return utils[_0x7b4c('0x15')](_0x390d28,0x0,![],null)[_0x7b4c('0x11')](function(){return utils[_0x7b4c('0x17')](_0x390d28);})[_0x7b4c('0x11')](function(){return _0x5905c8(null,_0x390d28);});}}else{return _0x5905c8(null,![],{'message':_0x7b4c('0x12')});}}else{return utils[_0x7b4c('0x15')](_0x390d28,0x0,![],null)['then'](function(){return utils[_0x7b4c('0x17')](_0x390d28);})['then'](function(){return _0x5905c8(null,_0x390d28);})[_0x7b4c('0x18')](function(_0x10066c){return _0x5905c8(null,![],_0x10066c);});}}else{if(_0x390d28[_0x7b4c('0x19')]){return _0x5905c8(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils[_0x7b4c('0x17')](_0x390d28)[_0x7b4c('0x11')](function(){return _0x5905c8(null,_0x390d28);});}}}});})[_0x7b4c('0x18')](function(_0x4a2b36){return _0x5905c8(null,![],_0x4a2b36);});}function sendServiceMail(_0x3b52b1){return db[_0x7b4c('0x1a')]['find']({'where':{'service':!![]},'attributes':['id',_0x7b4c('0xb'),'email'],'include':[{'model':db[_0x7b4c('0x1b')],'as':_0x7b4c('0x1c')}]})['then'](function(_0x3d6ab1){if(!_0x3d6ab1){throw new Error(_0x7b4c('0x1d'));}var _0x504695={'tls':{'rejectUnauthorized':![]}};if(_0x3d6ab1['Smtp']['service']){_0x504695[_0x7b4c('0x1e')]=_0x3d6ab1[_0x7b4c('0x1c')]['service'];}else{_0x504695[_0x7b4c('0x1f')]=_0x3d6ab1['Smtp'][_0x7b4c('0x1f')];_0x504695[_0x7b4c('0x20')]=_0x3d6ab1[_0x7b4c('0x1c')][_0x7b4c('0x20')];_0x504695[_0x7b4c('0x21')]=_0x3d6ab1[_0x7b4c('0x1c')]['secure'];}if(_0x3d6ab1[_0x7b4c('0x1c')][_0x7b4c('0x22')]){_0x504695[_0x7b4c('0x23')]={'user':_0x3d6ab1['Smtp'][_0x7b4c('0xf')],'pass':_0x3d6ab1[_0x7b4c('0x1c')][_0x7b4c('0x24')]};}var _0x5ab237={'account':_0x504695,'message':_[_0x7b4c('0x25')]({'from':util['format'](_0x7b4c('0x26'),_0x3d6ab1[_0x7b4c('0xb')],_0x3d6ab1['email']||_0x3d6ab1[_0x7b4c('0x1c')][_0x7b4c('0xf')])},_0x3b52b1)};return client['request'](_0x7b4c('0x27'),_0x5ab237);})[_0x7b4c('0x11')](function(_0x45e6db){if(_0x45e6db[_0x7b4c('0x28')]){throw new Error(util[_0x7b4c('0x29')](_0x7b4c('0x2a'),_0x45e6db[_0x7b4c('0x28')]['message']||JSON[_0x7b4c('0x2b')](_0x45e6db[_0x7b4c('0x28')])));}return!![];});}function handleError(_0x51b1af,_0x54a074,_0x309320){return _0x51b1af[_0x7b4c('0x2c')](_0x54a074||0x1f4)['send']({'message':_0x309320?_0x309320[_0x7b4c('0x2d')]||_0x309320:''});}function checkPasswordPattern(_0x3cf8a3,_0x4f44da,_0x33d650){if(_0x33d650){var _0x34f9a8=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x34f9a8[_0x7b4c('0x2e')](_0x4f44da)){return _0x3cf8a3;}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 _0x3cf8a3;}}exports['login']=function(_0xf08f83,_0x301b19,_0x443277){passport[_0x7b4c('0x2f')](_0x7b4c('0x30'),function(_0x58d9f7,_0x36bf10,_0x3b9bbe){var _0x29121a=_0x58d9f7||_0x3b9bbe;if(_0x29121a){return handleError(_0x301b19,0x191,_0x29121a);}if(!_0x36bf10){return handleError(_0x301b19,0x194,{'message':_0x7b4c('0x31')});}else{var _0x5f1bd9={'payload':{'id':_0x36bf10['id'],'role':_0x36bf10['role']},'options':{'expiresIn':0x15180}};return authService['signToken'](_0x5f1bd9)[_0x7b4c('0x11')](function(_0x118209){_0x301b19[_0x7b4c('0x32')]({'id':_0x36bf10['id'],'token':_0x118209,'statusCall':'','isAlreadyLogged':_0x36bf10[_0x7b4c('0x33')]});});}})(_0xf08f83,_0x301b19,_0x443277);};exports['forgot']=function(_0x471229,_0x3107d1,_0x3f90f7){if(!_0x471229['body']['email']){return handleError(_0x3107d1,0x1f4,{'message':_0x7b4c('0x34')});}var _0x34574c=rs[_0x7b4c('0x35')]();_0x471229[_0x7b4c('0x36')][_0x7b4c('0x37')]=_0x471229[_0x7b4c('0x36')][_0x7b4c('0x37')][_0x7b4c('0x38')]()['toLowerCase']();var _0x589000;return db['Setting'][_0x7b4c('0x8')]({'where':{'id':0x1},'attributes':[_0x7b4c('0x9'),_0x7b4c('0xa')],'raw':!![]})[_0x7b4c('0x11')](function(_0x41da3b){_0x589000=_0x41da3b;return db[_0x7b4c('0x39')][_0x7b4c('0x3a')]({'where':{'email':_0x471229[_0x7b4c('0x36')][_0x7b4c('0x37')]}});})[_0x7b4c('0x11')](function(_0x27215e){if(!_0x27215e){throw new Error(_0x7b4c('0x3b'));}if(_0x27215e[_0x7b4c('0x13')]){throw new Error('The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.');}if(_0x27215e[_0x7b4c('0x19')]){if(moment(_0x27215e[_0x7b4c('0xd')])[_0x7b4c('0x14')](_0x589000['blockDuration'],'minutes')>moment()){throw new Error('The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.');}else{_0x27215e[_0x7b4c('0x19')]=![];_0x27215e[_0x7b4c('0xd')]=null;}}_0x27215e[_0x7b4c('0x3c')]=_0x34574c;_0x27215e[_0x7b4c('0x3d')]=Date['now']()+0x36ee80;return _0x27215e[_0x7b4c('0x3e')]();})['then'](function(){return sendServiceMail({'to':_0x471229[_0x7b4c('0x36')][_0x7b4c('0x37')],'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'+_0x7b4c('0x3f')+_0x7b4c('0x40')+_0x471229[_0x7b4c('0x41')][_0x7b4c('0x1f')]+_0x7b4c('0x42')+_0x34574c+'\x0a\x0a'+_0x7b4c('0x43')});})[_0x7b4c('0x11')](function(){_0x3107d1[_0x7b4c('0x2c')](0xc8)[_0x7b4c('0x44')]({'message':_0x7b4c('0x45')});})[_0x7b4c('0x18')](function(_0x5bc9fe){return handleError(_0x3107d1,0x1f4,_0x5bc9fe);});};exports[_0x7b4c('0x46')]=function(_0x18bbc0,_0x29ff26,_0x249c2a){var _0x2240f3;return db[_0x7b4c('0x39')][_0x7b4c('0x3a')]({'where':{'resetPasswordToken':_0x18bbc0[_0x7b4c('0x47')][_0x7b4c('0x48')],'resetPasswordExpires':{'$gt':Date['now']()}}})[_0x7b4c('0x11')](function(_0x4b6126){_0x2240f3=_0x4b6126;if(!_0x2240f3){throw new Error(_0x7b4c('0x49'));}return db['Setting'][_0x7b4c('0x8')]({'attributes':['id',_0x7b4c('0x4a')]});})[_0x7b4c('0x11')](function(_0x1f9157){return checkPasswordPattern(_0x1f9157,_0x18bbc0[_0x7b4c('0x36')]['password'],_0x1f9157[_0x7b4c('0x4a')]);})[_0x7b4c('0x11')](function(){_0x2240f3[_0x7b4c('0xc')]=_0x18bbc0[_0x7b4c('0x36')]['password'];_0x2240f3[_0x7b4c('0x3c')]=null;_0x2240f3[_0x7b4c('0x3d')]=null;return _0x2240f3[_0x7b4c('0x3e')]();})[_0x7b4c('0x11')](function(){_0x29ff26[_0x7b4c('0x2c')](0xc8)[_0x7b4c('0x44')]({'message':_0x7b4c('0x4b')});})[_0x7b4c('0x18')](function(_0x4f4ee6){return handleError(_0x29ff26,0x1f4,_0x4f4ee6);});};passport[_0x7b4c('0x4c')](new LocalStrategy({'usernameField':'name','passwordField':_0x7b4c('0xc')},function(_0x127a2f,_0x1fe74e,_0x1ab2bb){return localAuthenticate(db[_0x7b4c('0x39')],_0x127a2f,_0x1fe74e,_0x1ab2bb);}));
\ No newline at end of file