Built motion from commit 4d2cf597c.|1.0.26
[motion.git] / server / auth / auth.service.js
index 488ccb0..67a8d68 100644 (file)
@@ -1 +1 @@
-var _0x83c5=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x70\x61\x73\x73\x70\x6F\x72\x74","\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x6A\x73\x6F\x6E\x77\x65\x62\x74\x6F\x6B\x65\x6E","\x65\x78\x70\x72\x65\x73\x73\x2D\x6A\x77\x74","\x63\x6F\x6D\x70\x6F\x73\x61\x62\x6C\x65\x2D\x6D\x69\x64\x64\x6C\x65\x77\x61\x72\x65","\x55\x73\x65\x72","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4C\x69\x73\x74","\x73\x65\x63\x72\x65\x74","\x73\x65\x73\x73\x69\x6F\x6E","\x62\x6C\x75\x65\x62\x69\x72\x64","\x6C\x6F\x64\x61\x73\x68","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x75\x73\x65\x72","\x74\x68\x65\x6E","\x69\x64","\x66\x69\x6E\x64\x42\x79\x49\x64","\x75\x73\x65","\x71\x75\x65\x72\x79","\x61\x63\x63\x65\x73\x73\x5F\x74\x6F\x6B\x65\x6E","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x61\x75\x74\x68\x6F\x72\x69\x7A\x61\x74\x69\x6F\x6E","\x68\x65\x61\x64\x65\x72\x73","\x42\x65\x61\x72\x65\x72\x20","\x42\x61\x73\x69\x63","\x73\x74\x61\x72\x74\x73\x57\x69\x74\x68","\x20","\x73\x70\x6C\x69\x74","\x61\x73\x63\x69\x69","\x62\x61\x73\x65\x36\x34","\x3A","\x61\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65","\x57\x72\x6F\x6E\x67\x20\x63\x72\x65\x64\x65\x6E\x74\x69\x61\x6C\x73\x2E","\x66\x69\x6E\x64\x4F\x6E\x65","\x72\x65\x64\x75\x63\x65","\x72\x6F\x6C\x65","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x68\x61\x73\x4D\x6F\x64\x75\x6C\x65","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x61\x6C\x6C","\x52\x65\x71\x75\x69\x72\x65\x64\x20\x72\x6F\x6C\x65\x20\x6E\x65\x65\x64\x73\x20\x74\x6F\x20\x62\x65\x20\x73\x65\x74","\x69\x6E\x64\x65\x78\x4F\x66","\x75\x73\x65\x72\x52\x6F\x6C\x65\x73","\x31\x64","\x73\x69\x67\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x77\x65\x6E\x74\x20\x77\x72\x6F\x6E\x67\x2C\x20\x70\x6C\x65\x61\x73\x65\x20\x74\x72\x79\x20\x61\x67\x61\x69\x6E\x2E","\x6A\x73\x6F\x6E","\x74\x6F\x6B\x65\x6E","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x63\x6F\x6F\x6B\x69\x65","\x2F","\x72\x65\x64\x69\x72\x65\x63\x74","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x68\x61\x73\x52\x6F\x6C\x65","\x73\x69\x67\x6E\x54\x6F\x6B\x65\x6E","\x73\x65\x74\x54\x6F\x6B\x65\x6E\x43\x6F\x6F\x6B\x69\x65"];_0x83c5[0];var passport=require(_0x83c5[1]);var config=require(_0x83c5[2]);var jwt=require(_0x83c5[3]);var expressJwt=require(_0x83c5[4]);var compose=require(_0x83c5[5]);var User=require(_0x83c5[7])[_0x83c5[6]];var List=require(_0x83c5[7])[_0x83c5[8]];var validateJwt=expressJwt({secret:config[_0x83c5[10]][_0x83c5[9]]});var Promise=require(_0x83c5[11]);var _=require(_0x83c5[12]);function isAuthenticated(){return compose()[_0x83c5[19]](function(_0xe63bxc,_0xe63bxd,_0xe63bxe){if(_0xe63bxc[_0x83c5[20]]&&_0xe63bxc[_0x83c5[20]][_0x83c5[22]](_0x83c5[21])){_0xe63bxc[_0x83c5[24]][_0x83c5[23]]=_0x83c5[25]+_0xe63bxc[_0x83c5[20]][_0x83c5[21]]};if(_0xe63bxc[_0x83c5[24]]&&_0xe63bxc[_0x83c5[24]][_0x83c5[23]]&&_[_0x83c5[27]](_0xe63bxc[_0x83c5[24]][_0x83c5[23]],_0x83c5[26])){var _0xe63bx11=_[_0x83c5[29]](_0xe63bxc[_0x83c5[24]][_0x83c5[23]],_0x83c5[28]);var _0xe63bx12= new Buffer(_0xe63bx11[1],_0x83c5[31]).toString(_0x83c5[30]);var _0xe63bx13=_[_0x83c5[29]](_0xe63bx12,_0x83c5[32])[0];var _0xe63bx14=_[_0x83c5[29]](_0xe63bx12,_0x83c5[32])[1];return User[_0x83c5[35]]({where:{name:_0xe63bx13}})[_0x83c5[16]](function(_0xe63bx10){if(!_0xe63bx10||!_0xe63bx10[_0x83c5[33]](_0xe63bx14)){_0xe63bxe( new Error(_0x83c5[34]))};_0xe63bxc[_0x83c5[15]]={id:_0xe63bx10[_0x83c5[17]]};_0xe63bxe()})}else {validateJwt(_0xe63bxc,_0xe63bxd,_0xe63bxe)}})[_0x83c5[19]](function(_0xe63bxc,_0xe63bxd,_0xe63bxe){User[_0x83c5[18]](_0xe63bxc[_0x83c5[15]][_0x83c5[17]],{include:[{model:List}]})[_0x83c5[16]](function(_0xe63bx10){if(!_0xe63bx10){return _0xe63bxd[_0x83c5[14]](401)};_0xe63bxc[_0x83c5[15]]=_0xe63bx10;return _0xe63bxe()})[_0x83c5[13]](function(_0xe63bxf){return _0xe63bxe(_0xe63bxf)})})}function hasModule(_0xe63bx16,_0xe63bx17){return compose()[_0x83c5[19]](function(_0xe63bxc,_0xe63bxd,_0xe63bxe){return User[_0x83c5[18]](_0xe63bxc[_0x83c5[15]][_0x83c5[17]])[_0x83c5[16]](function(_0xe63bx10){var _0xe63bx1b=[];_0xe63bx16[_0x83c5[41]](function(_0xe63bx1c){_0xe63bx1b[_0x83c5[40]](_0xe63bx10[_0x83c5[39]](_0xe63bx1c))});return Promise[_0x83c5[42]](_0xe63bx1b)})[_0x83c5[16]](function(_0xe63bx18){var hasModule=(_[_0x83c5[36]](_0xe63bx18,function(_0xe63bx19,_0xe63bx1a){return _0xe63bx19||_0xe63bx1a}));if(_[_0x83c5[38]](_0xe63bx17,_0xe63bxc[_0x83c5[15]][_0x83c5[37]])||hasModule){return _0xe63bxe()}else {_0xe63bxd[_0x83c5[14]](403)}})[_0x83c5[13]](function(_0xe63bxf){return _0xe63bxe(_0xe63bxf)})})}function hasRole(_0xe63bx1e){if(!_0xe63bx1e){throw  new Error(_0x83c5[43])};return compose()[_0x83c5[19]](isAuthenticated())[_0x83c5[19]](function _0xe63bx1f(_0xe63bxc,_0xe63bxd,_0xe63bxe){if(config[_0x83c5[45]][_0x83c5[44]](_0xe63bxc[_0x83c5[15]][_0x83c5[37]])>=config[_0x83c5[45]][_0x83c5[44]](_0xe63bx1e)){return _0xe63bxe()}else {return _0xe63bxd[_0x83c5[14]](403)}})}function signToken(_0xe63bx21,_0xe63bx22,_0xe63bx23){var _0xe63bx24=60*24*365*5;if(!_0xe63bx23){_0xe63bx24=_0x83c5[46]};return jwt[_0x83c5[47]]({id:_0xe63bx21},config[_0x83c5[10]][_0x83c5[9]],{expiresIn:_0xe63bx24})}function setTokenCookie(_0xe63bxc,_0xe63bxd){if(!_0xe63bxc[_0x83c5[15]]){return _0xe63bxd[_0x83c5[49]](404,{message:_0x83c5[48]})};var _0xe63bx26=signToken(_0xe63bxc[_0x83c5[15]][_0x83c5[17]],_0xe63bxc[_0x83c5[15]][_0x83c5[37]]);_0xe63bxd[_0x83c5[52]](_0x83c5[50],JSON[_0x83c5[51]](_0xe63bx26));_0xe63bxd[_0x83c5[54]](_0x83c5[53])}exports[_0x83c5[55]]=isAuthenticated;exports[_0x83c5[56]]=hasRole;exports[_0x83c5[39]]=hasModule;exports[_0x83c5[57]]=signToken;exports[_0x83c5[58]]=setTokenCookie
\ No newline at end of file
+var _0x67ef=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x70\x61\x73\x73\x70\x6F\x72\x74","\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x6A\x73\x6F\x6E\x77\x65\x62\x74\x6F\x6B\x65\x6E","\x65\x78\x70\x72\x65\x73\x73\x2D\x6A\x77\x74","\x63\x6F\x6D\x70\x6F\x73\x61\x62\x6C\x65\x2D\x6D\x69\x64\x64\x6C\x65\x77\x61\x72\x65","\x55\x73\x65\x72","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4C\x69\x73\x74","\x73\x65\x63\x72\x65\x74","\x73\x65\x73\x73\x69\x6F\x6E","\x62\x6C\x75\x65\x62\x69\x72\x64","\x6C\x6F\x64\x61\x73\x68","\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x6F\x67\x67\x65\x72\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x75\x73\x65\x72","\x47\x45\x54","\x50\x4F\x53\x54","\x50\x55\x54","\x50\x41\x54\x43\x48","\x75\x73\x65\x72\x49\x64\x3A\x20\x25\x73\x2C\x20\x75\x73\x65\x72\x4E\x61\x6D\x65\x3A\x20\x25\x73\x2C\x20\x6D\x65\x74\x68\x6F\x64\x3A\x20\x25\x73\x2C\x20\x70\x61\x74\x68\x3A\x20\x27\x25\x73\x27\x2C\x20\x62\x6F\x64\x79\x3A\x20\x25\x73","\x69\x64","\x6E\x61\x6D\x65","\x6D\x65\x74\x68\x6F\x64","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x55\x72\x6C","\x62\x6F\x64\x79","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x2D\x2D","\x69\x6E\x66\x6F","\x44\x45\x4C\x45\x54\x45","\x55\x6E\x6B\x6E\x6F\x77\x6E\x20\x72\x65\x71\x75\x65\x73\x74\x20\x6D\x65\x74\x68\x6F\x64\x2E","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x42\x79\x49\x64","\x75\x73\x65","\x71\x75\x65\x72\x79","\x61\x63\x63\x65\x73\x73\x5F\x74\x6F\x6B\x65\x6E","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x61\x75\x74\x68\x6F\x72\x69\x7A\x61\x74\x69\x6F\x6E","\x68\x65\x61\x64\x65\x72\x73","\x42\x65\x61\x72\x65\x72\x20","\x42\x61\x73\x69\x63","\x73\x74\x61\x72\x74\x73\x57\x69\x74\x68","\x20","\x73\x70\x6C\x69\x74","\x61\x73\x63\x69\x69","\x62\x61\x73\x65\x36\x34","\x3A","\x61\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65","\x57\x72\x6F\x6E\x67\x20\x63\x72\x65\x64\x65\x6E\x74\x69\x61\x6C\x73\x2E","\x66\x69\x6E\x64\x4F\x6E\x65","\x72\x65\x64\x75\x63\x65","\x72\x6F\x6C\x65","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x68\x61\x73\x4D\x6F\x64\x75\x6C\x65","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x61\x6C\x6C","\x52\x65\x71\x75\x69\x72\x65\x64\x20\x72\x6F\x6C\x65\x20\x6E\x65\x65\x64\x73\x20\x74\x6F\x20\x62\x65\x20\x73\x65\x74","\x69\x6E\x64\x65\x78\x4F\x66","\x75\x73\x65\x72\x52\x6F\x6C\x65\x73","\x31\x64","\x73\x69\x67\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x77\x65\x6E\x74\x20\x77\x72\x6F\x6E\x67\x2C\x20\x70\x6C\x65\x61\x73\x65\x20\x74\x72\x79\x20\x61\x67\x61\x69\x6E\x2E","\x6A\x73\x6F\x6E","\x74\x6F\x6B\x65\x6E","\x63\x6F\x6F\x6B\x69\x65","\x2F","\x72\x65\x64\x69\x72\x65\x63\x74","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x68\x61\x73\x52\x6F\x6C\x65","\x73\x69\x67\x6E\x54\x6F\x6B\x65\x6E","\x73\x65\x74\x54\x6F\x6B\x65\x6E\x43\x6F\x6F\x6B\x69\x65"];_0x67ef[0];var passport=require(_0x67ef[1]);var config=require(_0x67ef[2]);var jwt=require(_0x67ef[3]);var expressJwt=require(_0x67ef[4]);var compose=require(_0x67ef[5]);var User=require(_0x67ef[7])[_0x67ef[6]];var List=require(_0x67ef[7])[_0x67ef[8]];var validateJwt=expressJwt({secret:config[_0x67ef[10]][_0x67ef[9]]});var Promise=require(_0x67ef[11]);var _=require(_0x67ef[12]);var logger=require(_0x67ef[13]);function isAuthenticated(){return compose()[_0x67ef[34]](function(_0x22e0xd,_0x22e0xe,_0x22e0xf){if(_0x22e0xd[_0x67ef[35]]&& _0x22e0xd[_0x67ef[35]][_0x67ef[37]](_0x67ef[36])){_0x22e0xd[_0x67ef[39]][_0x67ef[38]]= _0x67ef[40]+ _0x22e0xd[_0x67ef[35]][_0x67ef[36]]};if(_0x22e0xd[_0x67ef[39]]&& _0x22e0xd[_0x67ef[39]][_0x67ef[38]]&& _[_0x67ef[42]](_0x22e0xd[_0x67ef[39]][_0x67ef[38]],_0x67ef[41])){var _0x22e0x12=_[_0x67ef[44]](_0x22e0xd[_0x67ef[39]][_0x67ef[38]],_0x67ef[43]);var _0x22e0x13= new Buffer(_0x22e0x12[1],_0x67ef[46]).toString(_0x67ef[45]);var _0x22e0x14=_[_0x67ef[44]](_0x22e0x13,_0x67ef[47])[0];var _0x22e0x15=_[_0x67ef[44]](_0x22e0x13,_0x67ef[47])[1];return User[_0x67ef[50]]({where:{name:_0x22e0x14}})[_0x67ef[32]](function(_0x22e0x11){if(!_0x22e0x11||  !_0x22e0x11[_0x67ef[48]](_0x22e0x15)){_0x22e0xf( new Error(_0x67ef[49]))};_0x22e0xd[_0x67ef[16]]= {id:_0x22e0x11[_0x67ef[22]]};_0x22e0xf()})}else {validateJwt(_0x22e0xd,_0x22e0xe,_0x22e0xf)}})[_0x67ef[34]](function(_0x22e0xd,_0x22e0xe,_0x22e0xf){User[_0x67ef[33]](_0x22e0xd[_0x67ef[16]][_0x67ef[22]],{include:[{model:List}]})[_0x67ef[32]](function(_0x22e0x11){if(!_0x22e0x11){return _0x22e0xe[_0x67ef[15]](401)};_0x22e0xd[_0x67ef[16]]= _0x22e0x11;switch(_0x22e0xd[_0x67ef[24]]){case _0x67ef[17]:break;case _0x67ef[18]:;case _0x67ef[19]:;case _0x67ef[20]:;case _0x67ef[30]:logger[_0x67ef[29]](_0x67ef[21],_0x22e0xd[_0x67ef[16]][_0x67ef[22]],_0x22e0xd[_0x67ef[16]][_0x67ef[23]],_0x22e0xd[_0x67ef[24]],_0x22e0xd[_0x67ef[25]],_0x22e0xd[_0x67ef[26]]?JSON[_0x67ef[27]](_0x22e0xd[_0x67ef[26]]):_0x67ef[28]);break;default:logger[_0x67ef[29]](_0x67ef[31])};return _0x22e0xf()})[_0x67ef[14]](function(_0x22e0x10){return _0x22e0xf(_0x22e0x10)})})}function hasModule(_0x22e0x17,_0x22e0x18){return compose()[_0x67ef[34]](function(_0x22e0xd,_0x22e0xe,_0x22e0xf){return User[_0x67ef[33]](_0x22e0xd[_0x67ef[16]][_0x67ef[22]])[_0x67ef[32]](function(_0x22e0x11){var _0x22e0x1c=[];_0x22e0x17[_0x67ef[56]](function(_0x22e0x1d){_0x22e0x1c[_0x67ef[55]](_0x22e0x11[_0x67ef[54]](_0x22e0x1d))});return Promise[_0x67ef[57]](_0x22e0x1c)})[_0x67ef[32]](function(_0x22e0x19){var hasModule=(_[_0x67ef[51]](_0x22e0x19,function(_0x22e0x1a,_0x22e0x1b){return _0x22e0x1a|| _0x22e0x1b}));if(_[_0x67ef[53]](_0x22e0x18,_0x22e0xd[_0x67ef[16]][_0x67ef[52]])|| hasModule){return _0x22e0xf()}else {_0x22e0xe[_0x67ef[15]](403)}})[_0x67ef[14]](function(_0x22e0x10){return _0x22e0xf(_0x22e0x10)})})}function hasRole(_0x22e0x1f){if(!_0x22e0x1f){throw  new Error(_0x67ef[58])};return compose()[_0x67ef[34]](isAuthenticated())[_0x67ef[34]](function _0x22e0x20(_0x22e0xd,_0x22e0xe,_0x22e0xf){if(config[_0x67ef[60]][_0x67ef[59]](_0x22e0xd[_0x67ef[16]][_0x67ef[52]])>= config[_0x67ef[60]][_0x67ef[59]](_0x22e0x1f)){return _0x22e0xf()}else {return _0x22e0xe[_0x67ef[15]](403)}})}function signToken(_0x22e0x22,_0x22e0x23,_0x22e0x24){var _0x22e0x25=60* 24* 365* 5;if(!_0x22e0x24){_0x22e0x25= _0x67ef[61]};return jwt[_0x67ef[62]]({id:_0x22e0x22},config[_0x67ef[10]][_0x67ef[9]],{expiresIn:_0x22e0x25})}function setTokenCookie(_0x22e0xd,_0x22e0xe){if(!_0x22e0xd[_0x67ef[16]]){return _0x22e0xe[_0x67ef[64]](404,{message:_0x67ef[63]})};var _0x22e0x27=signToken(_0x22e0xd[_0x67ef[16]][_0x67ef[22]],_0x22e0xd[_0x67ef[16]][_0x67ef[52]]);_0x22e0xe[_0x67ef[66]](_0x67ef[65],JSON[_0x67ef[27]](_0x22e0x27));_0x22e0xe[_0x67ef[68]](_0x67ef[67])}exports[_0x67ef[69]]= isAuthenticated;exports[_0x67ef[70]]= hasRole;exports[_0x67ef[54]]= hasModule;exports[_0x67ef[71]]= signToken;exports[_0x67ef[72]]= setTokenCookie
\ No newline at end of file