Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / authLocal / authLocal.controller.js
index e0bd996..393945f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1c59=['catch','MailAccount','find','email','MailServerOut','Smtp','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','service','host','port','secure','authentication','auth','user','pass','merge','format','\x22%s\x22\x20<%s>','request','error','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','message','status','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~!@#$%^&-_=+[{]}.','local','Something\x20went\x20wrong,\x20please\x20try\x20again.','role','json','online','forgot','Email\x20parameter\x20is\x20missing','generate','body','trim','toLowerCase','User','This\x20email\x20is\x20not\x20registered.','The\x20user\x20is\x20disabled.\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','http://','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','Reset\x20Email\x20sent!','params','token','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','securePassword','password','Password\x20reset!','use','util','passport','passport-local','Strategy','jayson/promise','lodash','moment','client','Setting','allowedLoginAttempts','blockDuration','then','findOne','name','salt','blocked','blockedAt','admin','agent','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','authenticate','loginAttempts','disabled','minutes','clearBlockUser','add','getLicense'];(function(_0x4ddc58,_0x10912c){var _0x34de9f=function(_0x5e57fa){while(--_0x5e57fa){_0x4ddc58['push'](_0x4ddc58['shift']());}};_0x34de9f(++_0x10912c);}(_0x1c59,0x18e));var _0x91c5=function(_0x39ea5f,_0xad7c1c){_0x39ea5f=_0x39ea5f-0x0;var _0x41d0c4=_0x1c59[_0x39ea5f];return _0x41d0c4;};'use strict';var util=require(_0x91c5('0x0'));var passport=require(_0x91c5('0x1'));var LocalStrategy=require(_0x91c5('0x2'))[_0x91c5('0x3')];var jayson=require(_0x91c5('0x4'));var _=require(_0x91c5('0x5'));var rs=require('randomstring');var moment=require(_0x91c5('0x6'));var db=require('../../mysqldb')['db'];var authService=require('../../components/auth/service');var utils=require('../../config/utils');var client=jayson[_0x91c5('0x7')]['http']({'port':0x232b});function localAuthenticate(_0x135d6b,_0x3a9b48,_0x49f7f8,_0x580c32){var _0x1754b5,_0x1660a4;return db[_0x91c5('0x8')]['findOne']({'where':{'id':0x1},'attributes':[_0x91c5('0x9'),_0x91c5('0xa')],'raw':!![]})[_0x91c5('0xb')](function(_0x3b27d5){_0x1754b5=_0x3b27d5;return _0x135d6b[_0x91c5('0xc')]({'attributes':['id',_0x91c5('0xd'),'password',_0x91c5('0xe'),'role','disabled',_0x91c5('0xf'),_0x91c5('0x10'),'loginAttempts'],'where':{'name':_0x3a9b48,'role':{'$or':[_0x91c5('0x11'),'user',_0x91c5('0x12')]}}});})[_0x91c5('0xb')](function(_0x4db24d){if(!_0x4db24d||_0x4db24d&&_0x4db24d['name']!==_0x3a9b48){throw new Error(_0x91c5('0x13'));}else{_0x1660a4=_0x4db24d;return _0x1660a4;}})[_0x91c5('0xb')](function(){_0x1660a4[_0x91c5('0x14')](_0x49f7f8,function(_0x2b6747,_0x5f297b){var _0xf31b9e=_0x1660a4[_0x91c5('0x15')]+0x1;if(_0x2b6747){return _0x580c32(_0x2b6747);}else if(!_0x5f297b){if(_0x1660a4[_0x91c5('0x16')]){return _0x580c32(null,![],{'message':_0x91c5('0x13')});}else if(_0x1754b5[_0x91c5('0x9')]>0x0){if(_0x1660a4['blocked']){if(_0x1754b5[_0x91c5('0xa')]>0x0){if(moment(_0x1660a4['blockedAt'])['add'](_0x1754b5[_0x91c5('0xa')],_0x91c5('0x17'))>moment()){return _0x580c32(null,![],{'message':_0x91c5('0x13')});}else{return utils['clearBlockUser'](_0x1660a4,_0xf31b9e,![],null)['then'](function(){return _0x580c32(null,![],{'message':_0x91c5('0x13')});});}}else{return _0x580c32(null,![],{'message':_0x91c5('0x13')});}}else{if(_0xf31b9e>=_0x1754b5[_0x91c5('0x9')]){return utils[_0x91c5('0x18')](_0x1660a4,0x0,!![],moment())[_0x91c5('0xb')](function(){return _0x580c32(null,![],{'message':_0x91c5('0x13')});});}else{return utils[_0x91c5('0x18')](_0x1660a4,_0xf31b9e,![],null)[_0x91c5('0xb')](function(){return _0x580c32(null,![],{'message':_0x91c5('0x13')});});}}}else{return _0x580c32(null,![],{'message':_0x91c5('0x13')});}}else{if(_0x1660a4['disabled']){return _0x580c32(null,![],{'message':_0x91c5('0x13')});}else if(_0x1754b5[_0x91c5('0x9')]>0x0){if(_0x1660a4[_0x91c5('0xf')]){if(_0x1754b5[_0x91c5('0xa')]>0x0){if(moment(_0x1660a4[_0x91c5('0x10')])[_0x91c5('0x19')](_0x1754b5[_0x91c5('0xa')],_0x91c5('0x17'))>moment()){return _0x580c32(null,![],{'message':_0x91c5('0x13')});}else{return utils[_0x91c5('0x18')](_0x1660a4,0x0,![],null)[_0x91c5('0xb')](function(){return utils['getLicense'](_0x1660a4);})[_0x91c5('0xb')](function(){return _0x580c32(null,_0x1660a4);});}}else{return _0x580c32(null,![],{'message':_0x91c5('0x13')});}}else{return utils['clearBlockUser'](_0x1660a4,0x0,![],null)['then'](function(){return utils[_0x91c5('0x1a')](_0x1660a4);})['then'](function(){return _0x580c32(null,_0x1660a4);})[_0x91c5('0x1b')](function(_0x4a6655){return _0x580c32(null,![],_0x4a6655);});}}else{if(_0x1660a4[_0x91c5('0xf')]){return _0x580c32(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils['getLicense'](_0x1660a4)[_0x91c5('0xb')](function(){return _0x580c32(null,_0x1660a4);});}}}});})['catch'](function(_0x9923f8){return _0x580c32(null,![],_0x9923f8);});}function sendServiceMail(_0x189ad5){return db[_0x91c5('0x1c')][_0x91c5('0x1d')]({'where':{'service':!![]},'attributes':['id',_0x91c5('0xd'),_0x91c5('0x1e')],'include':[{'model':db[_0x91c5('0x1f')],'as':_0x91c5('0x20')}]})['then'](function(_0x2843fb){if(!_0x2843fb){throw new Error(_0x91c5('0x21'));}var _0x48b721={'tls':{'rejectUnauthorized':![]}};if(_0x2843fb[_0x91c5('0x20')][_0x91c5('0x22')]){_0x48b721[_0x91c5('0x22')]=_0x2843fb[_0x91c5('0x20')][_0x91c5('0x22')];}else{_0x48b721[_0x91c5('0x23')]=_0x2843fb[_0x91c5('0x20')][_0x91c5('0x23')];_0x48b721[_0x91c5('0x24')]=_0x2843fb['Smtp'][_0x91c5('0x24')];_0x48b721[_0x91c5('0x25')]=_0x2843fb[_0x91c5('0x20')]['secure'];}if(_0x2843fb[_0x91c5('0x20')][_0x91c5('0x26')]){_0x48b721[_0x91c5('0x27')]={'user':_0x2843fb['Smtp'][_0x91c5('0x28')],'pass':_0x2843fb[_0x91c5('0x20')][_0x91c5('0x29')]};}var _0x5742c7={'account':_0x48b721,'message':_[_0x91c5('0x2a')]({'from':util[_0x91c5('0x2b')](_0x91c5('0x2c'),_0x2843fb['name'],_0x2843fb[_0x91c5('0x1e')]||_0x2843fb['Smtp'][_0x91c5('0x28')])},_0x189ad5)};return client[_0x91c5('0x2d')]('SendMail',_0x5742c7);})[_0x91c5('0xb')](function(_0x29521b){if(_0x29521b[_0x91c5('0x2e')]){throw new Error(util[_0x91c5('0x2b')](_0x91c5('0x2f'),_0x29521b[_0x91c5('0x2e')][_0x91c5('0x30')]||JSON['stringify'](_0x29521b[_0x91c5('0x2e')])));}return!![];});}function handleError(_0x21d115,_0xa8ad7c,_0x4b9908){return _0x21d115[_0x91c5('0x31')](_0xa8ad7c||0x1f4)[_0x91c5('0x32')]({'message':_0x4b9908?_0x4b9908[_0x91c5('0x30')]||_0x4b9908:''});}function checkPasswordPattern(_0xc82d7c,_0x4a6b48,_0x334f99){if(_0x334f99){var _0x51bc8e=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x51bc8e[_0x91c5('0x33')](_0x4a6b48)){return _0xc82d7c;}else{throw new Error(_0x91c5('0x34'));}}else{return _0xc82d7c;}}exports['login']=function(_0x522c31,_0x116db6,_0x529cfe){passport[_0x91c5('0x14')](_0x91c5('0x35'),function(_0x4ac3f2,_0xe4e63c,_0x5a1600){var _0x235ccd=_0x4ac3f2||_0x5a1600;if(_0x235ccd){return handleError(_0x116db6,0x191,_0x235ccd);}if(!_0xe4e63c){return handleError(_0x116db6,0x194,{'message':_0x91c5('0x36')});}else{var _0x16362a={'payload':{'id':_0xe4e63c['id'],'role':_0xe4e63c[_0x91c5('0x37')]},'options':{'expiresIn':0x15180}};return authService['signToken'](_0x16362a)[_0x91c5('0xb')](function(_0x36d5f9){_0x116db6[_0x91c5('0x38')]({'id':_0xe4e63c['id'],'token':_0x36d5f9,'statusCall':'','isAlreadyLogged':_0xe4e63c[_0x91c5('0x39')]});});}})(_0x522c31,_0x116db6,_0x529cfe);};exports[_0x91c5('0x3a')]=function(_0x480163,_0x12aea2,_0x22e8d5){if(!_0x480163['body'][_0x91c5('0x1e')]){return handleError(_0x12aea2,0x1f4,{'message':_0x91c5('0x3b')});}var _0x246b8e=rs[_0x91c5('0x3c')]();_0x480163[_0x91c5('0x3d')][_0x91c5('0x1e')]=_0x480163['body']['email'][_0x91c5('0x3e')]()[_0x91c5('0x3f')]();var _0x3f85be;return db[_0x91c5('0x8')]['findOne']({'where':{'id':0x1},'attributes':[_0x91c5('0x9'),_0x91c5('0xa')],'raw':!![]})[_0x91c5('0xb')](function(_0x1e648b){_0x3f85be=_0x1e648b;return db[_0x91c5('0x40')][_0x91c5('0x1d')]({'where':{'email':_0x480163['body'][_0x91c5('0x1e')]}});})['then'](function(_0x337ee2){if(!_0x337ee2){throw new Error(_0x91c5('0x41'));}if(_0x337ee2[_0x91c5('0x16')]){throw new Error(_0x91c5('0x42'));}if(_0x337ee2['blocked']){if(moment(_0x337ee2[_0x91c5('0x10')])[_0x91c5('0x19')](_0x3f85be['blockDuration'],_0x91c5('0x17'))>moment()){throw new Error('The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.');}else{_0x337ee2[_0x91c5('0xf')]=![];_0x337ee2['blockedAt']=null;}}_0x337ee2[_0x91c5('0x43')]=_0x246b8e;_0x337ee2[_0x91c5('0x44')]=Date[_0x91c5('0x45')]()+0x36ee80;return _0x337ee2[_0x91c5('0x46')]();})[_0x91c5('0xb')](function(){return sendServiceMail({'to':_0x480163[_0x91c5('0x3d')][_0x91c5('0x1e')],'subject':_0x91c5('0x47'),'text':_0x91c5('0x48')+_0x91c5('0x49')+_0x91c5('0x4a')+_0x480163['headers'][_0x91c5('0x23')]+_0x91c5('0x4b')+_0x246b8e+'\x0a\x0a'+_0x91c5('0x4c')});})[_0x91c5('0xb')](function(){_0x12aea2[_0x91c5('0x31')](0xc8)[_0x91c5('0x32')]({'message':_0x91c5('0x4d')});})[_0x91c5('0x1b')](function(_0x238124){return handleError(_0x12aea2,0x1f4,_0x238124);});};exports['reset']=function(_0x329734,_0x534901,_0x118d26){var _0x25eb75;return db[_0x91c5('0x40')]['find']({'where':{'resetPasswordToken':_0x329734[_0x91c5('0x4e')][_0x91c5('0x4f')],'resetPasswordExpires':{'$gt':Date[_0x91c5('0x45')]()}}})[_0x91c5('0xb')](function(_0x32bc2b){_0x25eb75=_0x32bc2b;if(!_0x25eb75){throw new Error(_0x91c5('0x50'));}return db[_0x91c5('0x8')][_0x91c5('0xc')]({'attributes':['id','securePassword']});})[_0x91c5('0xb')](function(_0x30ee81){return checkPasswordPattern(_0x30ee81,_0x329734[_0x91c5('0x3d')]['password'],_0x30ee81[_0x91c5('0x51')]);})['then'](function(){_0x25eb75[_0x91c5('0x52')]=_0x329734[_0x91c5('0x3d')]['password'];_0x25eb75[_0x91c5('0x43')]=null;_0x25eb75[_0x91c5('0x44')]=null;return _0x25eb75['save']();})[_0x91c5('0xb')](function(){_0x534901[_0x91c5('0x31')](0xc8)[_0x91c5('0x32')]({'message':_0x91c5('0x53')});})[_0x91c5('0x1b')](function(_0x9f929b){return handleError(_0x534901,0x1f4,_0x9f929b);});};passport[_0x91c5('0x54')](new LocalStrategy({'usernameField':_0x91c5('0xd'),'passwordField':'password'},function(_0x24a2c2,_0xa6453c,_0x7a5c1e){return localAuthenticate(db[_0x91c5('0x40')],_0x24a2c2,_0xa6453c,_0x7a5c1e);}));
\ No newline at end of file
+var _0x3463=['online','forgot','body','Email\x20parameter\x20is\x20missing','generate','trim','toLowerCase','User','This\x20email\x20is\x20not\x20registered.','The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.','resetPasswordToken','resetPasswordExpires','now','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','status','Reset\x20Email\x20sent!','reset','params','token','Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.','securePassword','validatePasswordPattern','enforcePasswordHistory','previousPasswords','validatePasswordHistory','Password\x20reset!','jayson/promise','randomstring','../../mysqldb','../../components/auth/service','../../config/utils','client','http','Setting','findOne','allowedLoginAttempts','blockDuration','then','name','password','role','disabled','admin','user','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','authenticate','blockedAt','add','minutes','clearBlockUser','blocked','catch','MailAccount','find','email','Smtp','CloudProvider','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','format','\x22%s\x22\x20<%s>','request','SendMail','error','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','send','message','local-login','Something\x20went\x20wrong,\x20please\x20try\x20again.','signToken','json'];(function(_0x32ccd6,_0x612cf3){var _0x15c41a=function(_0x39e65c){while(--_0x39e65c){_0x32ccd6['push'](_0x32ccd6['shift']());}};_0x15c41a(++_0x612cf3);}(_0x3463,0x1e1));var _0x3346=function(_0x2c3458,_0x1f7efd){_0x2c3458=_0x2c3458-0x0;var _0x3f7e02=_0x3463[_0x2c3458];return _0x3f7e02;};'use strict';var util=require('util');var passport=require('passport');var LocalStrategy=require('passport-local')['Strategy'];var jayson=require(_0x3346('0x0'));var _=require('lodash');var rs=require(_0x3346('0x1'));var moment=require('moment');var db=require(_0x3346('0x2'))['db'];var authService=require(_0x3346('0x3'));var utils=require(_0x3346('0x4'));var client=jayson[_0x3346('0x5')][_0x3346('0x6')]({'port':0x232b});function localAuthenticate(_0x1085a1,_0x1d2638,_0x18cd93,_0x2f1090){var _0x4c83d8,_0xad86ee;return db[_0x3346('0x7')][_0x3346('0x8')]({'where':{'id':0x1},'attributes':[_0x3346('0x9'),_0x3346('0xa')],'raw':!![]})[_0x3346('0xb')](function(_0x21e6f6){_0x4c83d8=_0x21e6f6;return _0x1085a1[_0x3346('0x8')]({'attributes':['id',_0x3346('0xc'),_0x3346('0xd'),'salt',_0x3346('0xe'),_0x3346('0xf'),'blocked','blockedAt','loginAttempts'],'where':{'name':_0x1d2638,'role':{'$or':[_0x3346('0x10'),_0x3346('0x11'),'agent']}}});})['then'](function(_0x4c2bc5){if(!_0x4c2bc5||_0x4c2bc5&&_0x4c2bc5[_0x3346('0xc')]!==_0x1d2638){throw new Error(_0x3346('0x12'));}else{_0xad86ee=_0x4c2bc5;return _0xad86ee;}})[_0x3346('0xb')](function(){_0xad86ee[_0x3346('0x13')](_0x18cd93,function(_0x2ea2db,_0x279d5d){var _0x4a94ce=_0xad86ee['loginAttempts']+0x1;if(_0x2ea2db){return _0x2f1090(_0x2ea2db);}else if(!_0x279d5d){if(_0xad86ee[_0x3346('0xf')]){return _0x2f1090(null,![],{'message':_0x3346('0x12')});}else if(_0x4c83d8[_0x3346('0x9')]>0x0){if(_0xad86ee['blocked']){if(_0x4c83d8[_0x3346('0xa')]>0x0){if(moment(_0xad86ee[_0x3346('0x14')])[_0x3346('0x15')](_0x4c83d8['blockDuration'],_0x3346('0x16'))>moment()){return _0x2f1090(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils[_0x3346('0x17')](_0xad86ee,_0x4a94ce,![],null)[_0x3346('0xb')](function(){return _0x2f1090(null,![],{'message':_0x3346('0x12')});});}}else{return _0x2f1090(null,![],{'message':_0x3346('0x12')});}}else{if(_0x4a94ce>=_0x4c83d8[_0x3346('0x9')]){return utils[_0x3346('0x17')](_0xad86ee,0x0,!![],moment())[_0x3346('0xb')](function(){return _0x2f1090(null,![],{'message':_0x3346('0x12')});});}else{return utils[_0x3346('0x17')](_0xad86ee,_0x4a94ce,![],null)[_0x3346('0xb')](function(){return _0x2f1090(null,![],{'message':_0x3346('0x12')});});}}}else{return _0x2f1090(null,![],{'message':_0x3346('0x12')});}}else{if(_0xad86ee['disabled']){return _0x2f1090(null,![],{'message':_0x3346('0x12')});}else if(_0x4c83d8[_0x3346('0x9')]>0x0){if(_0xad86ee[_0x3346('0x18')]){if(_0x4c83d8['blockDuration']>0x0){if(moment(_0xad86ee[_0x3346('0x14')])[_0x3346('0x15')](_0x4c83d8[_0x3346('0xa')],_0x3346('0x16'))>moment()){return _0x2f1090(null,![],{'message':_0x3346('0x12')});}else{return utils['clearBlockUser'](_0xad86ee,0x0,![],null)[_0x3346('0xb')](function(){return utils['getLicense'](_0xad86ee);})[_0x3346('0xb')](function(){return _0x2f1090(null,_0xad86ee);});}}else{return _0x2f1090(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}}else{return utils[_0x3346('0x17')](_0xad86ee,0x0,![],null)[_0x3346('0xb')](function(){return utils['getLicense'](_0xad86ee);})[_0x3346('0xb')](function(){return _0x2f1090(null,_0xad86ee);})['catch'](function(_0x49b43d){return _0x2f1090(null,![],_0x49b43d);});}}else{if(_0xad86ee[_0x3346('0x18')]){return _0x2f1090(null,![],{'message':_0x3346('0x12')});}else{return utils['getLicense'](_0xad86ee)[_0x3346('0xb')](function(){return _0x2f1090(null,_0xad86ee);});}}}});})[_0x3346('0x19')](function(_0x26763e){return _0x2f1090(null,![],_0x26763e);});}function sendServiceMail(_0x2f20c1){return db[_0x3346('0x1a')][_0x3346('0x1b')]({'where':{'service':!![]},'attributes':['id',_0x3346('0xc'),_0x3346('0x1c')],'include':[{'model':db['MailServerOut'],'as':_0x3346('0x1d'),'include':[{'model':db[_0x3346('0x1e')],'as':_0x3346('0x1e')}]}]})[_0x3346('0xb')](function(_0x22d458){if(!_0x22d458){throw new Error(_0x3346('0x1f'));}var _0x20e8f2=_0x22d458['getSmtpOptions']();var _0x32cbf3={'account':_0x20e8f2,'message':_['merge']({'from':util[_0x3346('0x20')](_0x3346('0x21'),_0x22d458['name'],_0x22d458[_0x3346('0x1c')]||_0x22d458[_0x3346('0x1d')][_0x3346('0x11')])},_0x2f20c1)};return client[_0x3346('0x22')](_0x3346('0x23'),_0x32cbf3);})[_0x3346('0xb')](function(_0x391077){if(_0x391077[_0x3346('0x24')]){throw new Error(util[_0x3346('0x20')](_0x3346('0x25'),_0x391077['error']['message']||JSON['stringify'](_0x391077[_0x3346('0x24')])));}return!![];});}function handleError(_0x41a926,_0x3bd1de,_0x387bdb){return _0x41a926['status'](_0x3bd1de||0x1f4)[_0x3346('0x26')]({'message':_0x387bdb?_0x387bdb[_0x3346('0x27')]||_0x387bdb:''});}exports['login']=function(_0x582468,_0x192114,_0xa935cd){passport[_0x3346('0x13')](_0x3346('0x28'),function(_0x542948,_0x50dd80,_0x30df55){var _0x59234d=_0x542948||_0x30df55;if(_0x59234d){return handleError(_0x192114,0x191,_0x59234d);}if(!_0x50dd80){return handleError(_0x192114,0x194,{'message':_0x3346('0x29')});}else{var _0x26ce27={'payload':{'id':_0x50dd80['id'],'role':_0x50dd80[_0x3346('0xe')]},'options':{'expiresIn':0x15180}};return authService[_0x3346('0x2a')](_0x26ce27)[_0x3346('0xb')](function(_0x4245e8){_0x192114[_0x3346('0x2b')]({'id':_0x50dd80['id'],'token':_0x4245e8,'statusCall':'','isAlreadyLogged':_0x50dd80[_0x3346('0x2c')]});});}})(_0x582468,_0x192114,_0xa935cd);};exports[_0x3346('0x2d')]=function(_0x4e39b9,_0x573663){if(!_0x4e39b9[_0x3346('0x2e')]['email']){return handleError(_0x573663,0x1f4,{'message':_0x3346('0x2f')});}var _0x1bcbbf=rs[_0x3346('0x30')]();_0x4e39b9[_0x3346('0x2e')][_0x3346('0x1c')]=_0x4e39b9[_0x3346('0x2e')][_0x3346('0x1c')][_0x3346('0x31')]()[_0x3346('0x32')]();var _0x536f48;return db[_0x3346('0x7')][_0x3346('0x8')]({'where':{'id':0x1},'attributes':[_0x3346('0x9'),_0x3346('0xa')],'raw':!![]})[_0x3346('0xb')](function(_0x34c6dc){_0x536f48=_0x34c6dc;return db[_0x3346('0x33')][_0x3346('0x1b')]({'where':{'email':_0x4e39b9[_0x3346('0x2e')][_0x3346('0x1c')]}});})[_0x3346('0xb')](function(_0x3e536a){if(!_0x3e536a){throw new Error(_0x3346('0x34'));}if(_0x3e536a['disabled']){throw new Error(_0x3346('0x35'));}if(_0x3e536a[_0x3346('0x18')]){if(moment(_0x3e536a[_0x3346('0x14')])[_0x3346('0x15')](_0x536f48[_0x3346('0xa')],'minutes')>moment()){throw new Error('The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.');}else{_0x3e536a[_0x3346('0x18')]=![];_0x3e536a[_0x3346('0x14')]=null;}}_0x3e536a[_0x3346('0x36')]=_0x1bcbbf;_0x3e536a[_0x3346('0x37')]=Date[_0x3346('0x38')]()+0x36ee80;return _0x3e536a['save']();})[_0x3346('0xb')](function(){return sendServiceMail({'to':_0x4e39b9[_0x3346('0x2e')]['email'],'subject':_0x3346('0x39'),'text':_0x3346('0x3a')+_0x3346('0x3b')+_0x3346('0x3c')+_0x4e39b9[_0x3346('0x3d')][_0x3346('0x3e')]+'/reset/'+_0x1bcbbf+'\x0a\x0a'+'If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a'});})[_0x3346('0xb')](function(){_0x573663[_0x3346('0x3f')](0xc8)[_0x3346('0x26')]({'message':_0x3346('0x40')});})[_0x3346('0x19')](function(_0x1b5e5b){return handleError(_0x573663,0x1f4,_0x1b5e5b);});};exports[_0x3346('0x41')]=function(_0x427f2c,_0x436199){return db[_0x3346('0x33')]['find']({'where':{'resetPasswordToken':_0x427f2c[_0x3346('0x42')][_0x3346('0x43')],'resetPasswordExpires':{'$gt':Date[_0x3346('0x38')]()}}})['then'](function(_0x503f6e){if(!_0x503f6e){throw new Error(_0x3346('0x44'));}return db[_0x3346('0x7')][_0x3346('0x8')]({'attributes':['id',_0x3346('0x45'),'enforcePasswordHistory','passwordHistoryLimit']})[_0x3346('0xb')](function(_0x35ee84){if(_0x35ee84['securePassword'])authService[_0x3346('0x46')](_0x427f2c[_0x3346('0x2e')][_0x3346('0xd')]);if(!_0x35ee84[_0x3346('0x47')]||!_0x503f6e[_0x3346('0x48')])return _0x503f6e;authService[_0x3346('0x49')](_0x427f2c[_0x3346('0x2e')]['password'],_0x503f6e[_0x3346('0x48')],_0x35ee84['passwordHistoryLimit']);return _0x503f6e;})['then'](function(){_0x503f6e[_0x3346('0xd')]=_0x427f2c[_0x3346('0x2e')][_0x3346('0xd')];_0x503f6e[_0x3346('0x36')]=null;_0x503f6e[_0x3346('0x37')]=null;return _0x503f6e['save']();});})[_0x3346('0xb')](function(){_0x436199[_0x3346('0x3f')](0xc8)[_0x3346('0x26')]({'message':_0x3346('0x4a')});})[_0x3346('0x19')](function(_0x31ce79){return handleError(_0x436199,0x1f4,_0x31ce79);});};passport['use'](_0x3346('0x28'),new LocalStrategy({'usernameField':_0x3346('0xc'),'passwordField':_0x3346('0xd')},function(_0xeb3f47,_0x114d41,_0xa96a3c){return localAuthenticate(db[_0x3346('0x33')],_0xeb3f47,_0x114d41,_0xa96a3c);}));
\ No newline at end of file