Built motion from commit 8abd872ce.|1.0.30
[motion.git] / server / auth / auth.service.js
index 8255113..9f753c1 100644 (file)
@@ -1 +1 @@
-var _0x72d9=["\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"];_0x72d9[0];var passport=require(_0x72d9[1]);var config=require(_0x72d9[2]);var jwt=require(_0x72d9[3]);var expressJwt=require(_0x72d9[4]);var compose=require(_0x72d9[5]);var User=require(_0x72d9[7])[_0x72d9[6]];var List=require(_0x72d9[7])[_0x72d9[8]];var validateJwt=expressJwt({secret:config[_0x72d9[10]][_0x72d9[9]]});var Promise=require(_0x72d9[11]);var _=require(_0x72d9[12]);var logger=require(_0x72d9[13]);function isAuthenticated(){return compose()[_0x72d9[34]](function(_0x8721xd,_0x8721xe,_0x8721xf){if(_0x8721xd[_0x72d9[35]]&& _0x8721xd[_0x72d9[35]][_0x72d9[37]](_0x72d9[36])){_0x8721xd[_0x72d9[39]][_0x72d9[38]]= _0x72d9[40]+ _0x8721xd[_0x72d9[35]][_0x72d9[36]]};if(_0x8721xd[_0x72d9[39]]&& _0x8721xd[_0x72d9[39]][_0x72d9[38]]&& _[_0x72d9[42]](_0x8721xd[_0x72d9[39]][_0x72d9[38]],_0x72d9[41])){var _0x8721x12=_[_0x72d9[44]](_0x8721xd[_0x72d9[39]][_0x72d9[38]],_0x72d9[43]);var _0x8721x13= new Buffer(_0x8721x12[1],_0x72d9[46]).toString(_0x72d9[45]);var _0x8721x14=_[_0x72d9[44]](_0x8721x13,_0x72d9[47])[0];var _0x8721x15=_[_0x72d9[44]](_0x8721x13,_0x72d9[47])[1];return User[_0x72d9[50]]({where:{name:_0x8721x14}})[_0x72d9[32]](function(_0x8721x11){if(!_0x8721x11||  !_0x8721x11[_0x72d9[48]](_0x8721x15)){_0x8721xf( new Error(_0x72d9[49]))};_0x8721xd[_0x72d9[16]]= {id:_0x8721x11[_0x72d9[22]]};_0x8721xf()})}else {validateJwt(_0x8721xd,_0x8721xe,_0x8721xf)}})[_0x72d9[34]](function(_0x8721xd,_0x8721xe,_0x8721xf){User[_0x72d9[33]](_0x8721xd[_0x72d9[16]][_0x72d9[22]],{include:[{model:List}]})[_0x72d9[32]](function(_0x8721x11){if(!_0x8721x11){return _0x8721xe[_0x72d9[15]](401)};_0x8721xd[_0x72d9[16]]= _0x8721x11;switch(_0x8721xd[_0x72d9[24]]){case _0x72d9[17]:break;case _0x72d9[18]:;case _0x72d9[19]:;case _0x72d9[20]:;case _0x72d9[30]:logger[_0x72d9[29]](_0x72d9[21],_0x8721xd[_0x72d9[16]][_0x72d9[22]],_0x8721xd[_0x72d9[16]][_0x72d9[23]],_0x8721xd[_0x72d9[24]],_0x8721xd[_0x72d9[25]],_0x8721xd[_0x72d9[26]]?JSON[_0x72d9[27]](_0x8721xd[_0x72d9[26]]):_0x72d9[28]);break;default:logger[_0x72d9[29]](_0x72d9[31])};return _0x8721xf()})[_0x72d9[14]](function(_0x8721x10){return _0x8721xf(_0x8721x10)})})}function hasModule(_0x8721x17,_0x8721x18){return compose()[_0x72d9[34]](function(_0x8721xd,_0x8721xe,_0x8721xf){return User[_0x72d9[33]](_0x8721xd[_0x72d9[16]][_0x72d9[22]])[_0x72d9[32]](function(_0x8721x11){var _0x8721x1c=[];_0x8721x17[_0x72d9[56]](function(_0x8721x1d){_0x8721x1c[_0x72d9[55]](_0x8721x11[_0x72d9[54]](_0x8721x1d))});return Promise[_0x72d9[57]](_0x8721x1c)})[_0x72d9[32]](function(_0x8721x19){var hasModule=(_[_0x72d9[51]](_0x8721x19,function(_0x8721x1a,_0x8721x1b){return _0x8721x1a|| _0x8721x1b}));if(_[_0x72d9[53]](_0x8721x18,_0x8721xd[_0x72d9[16]][_0x72d9[52]])|| hasModule){return _0x8721xf()}else {_0x8721xe[_0x72d9[15]](403)}})[_0x72d9[14]](function(_0x8721x10){return _0x8721xf(_0x8721x10)})})}function hasRole(_0x8721x1f){if(!_0x8721x1f){throw  new Error(_0x72d9[58])};return compose()[_0x72d9[34]](isAuthenticated())[_0x72d9[34]](function _0x8721x20(_0x8721xd,_0x8721xe,_0x8721xf){if(config[_0x72d9[60]][_0x72d9[59]](_0x8721xd[_0x72d9[16]][_0x72d9[52]])>= config[_0x72d9[60]][_0x72d9[59]](_0x8721x1f)){return _0x8721xf()}else {return _0x8721xe[_0x72d9[15]](403)}})}function signToken(_0x8721x22,_0x8721x23,_0x8721x24){var _0x8721x25=60* 24* 365* 5;if(!_0x8721x24){_0x8721x25= _0x72d9[61]};return jwt[_0x72d9[62]]({id:_0x8721x22},config[_0x72d9[10]][_0x72d9[9]],{expiresIn:_0x8721x25})}function setTokenCookie(_0x8721xd,_0x8721xe){if(!_0x8721xd[_0x72d9[16]]){return _0x8721xe[_0x72d9[64]](404,{message:_0x72d9[63]})};var _0x8721x27=signToken(_0x8721xd[_0x72d9[16]][_0x72d9[22]],_0x8721xd[_0x72d9[16]][_0x72d9[52]]);_0x8721xe[_0x72d9[66]](_0x72d9[65],JSON[_0x72d9[27]](_0x8721x27));_0x8721xe[_0x72d9[68]](_0x72d9[67])}exports[_0x72d9[69]]= isAuthenticated;exports[_0x72d9[70]]= hasRole;exports[_0x72d9[54]]= hasModule;exports[_0x72d9[71]]= signToken;exports[_0x72d9[72]]= setTokenCookie
\ No newline at end of file
+var _0xdf6f=["\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"];_0xdf6f[0];var passport=require(_0xdf6f[1]);var config=require(_0xdf6f[2]);var jwt=require(_0xdf6f[3]);var expressJwt=require(_0xdf6f[4]);var compose=require(_0xdf6f[5]);var User=require(_0xdf6f[7])[_0xdf6f[6]];var List=require(_0xdf6f[7])[_0xdf6f[8]];var validateJwt=expressJwt({secret:config[_0xdf6f[10]][_0xdf6f[9]]});var Promise=require(_0xdf6f[11]);var _=require(_0xdf6f[12]);var logger=require(_0xdf6f[13]);function isAuthenticated(){return compose()[_0xdf6f[34]](function(_0x17b7xd,_0x17b7xe,_0x17b7xf){if(_0x17b7xd[_0xdf6f[35]]&& _0x17b7xd[_0xdf6f[35]][_0xdf6f[37]](_0xdf6f[36])){_0x17b7xd[_0xdf6f[39]][_0xdf6f[38]]= _0xdf6f[40]+ _0x17b7xd[_0xdf6f[35]][_0xdf6f[36]]};if(_0x17b7xd[_0xdf6f[39]]&& _0x17b7xd[_0xdf6f[39]][_0xdf6f[38]]&& _[_0xdf6f[42]](_0x17b7xd[_0xdf6f[39]][_0xdf6f[38]],_0xdf6f[41])){var _0x17b7x12=_[_0xdf6f[44]](_0x17b7xd[_0xdf6f[39]][_0xdf6f[38]],_0xdf6f[43]);var _0x17b7x13= new Buffer(_0x17b7x12[1],_0xdf6f[46]).toString(_0xdf6f[45]);var _0x17b7x14=_[_0xdf6f[44]](_0x17b7x13,_0xdf6f[47])[0];var _0x17b7x15=_[_0xdf6f[44]](_0x17b7x13,_0xdf6f[47])[1];return User[_0xdf6f[50]]({where:{name:_0x17b7x14}})[_0xdf6f[32]](function(_0x17b7x11){if(!_0x17b7x11||  !_0x17b7x11[_0xdf6f[48]](_0x17b7x15)){_0x17b7xf( new Error(_0xdf6f[49]))};_0x17b7xd[_0xdf6f[16]]= {id:_0x17b7x11[_0xdf6f[22]]};_0x17b7xf()})}else {validateJwt(_0x17b7xd,_0x17b7xe,_0x17b7xf)}})[_0xdf6f[34]](function(_0x17b7xd,_0x17b7xe,_0x17b7xf){User[_0xdf6f[33]](_0x17b7xd[_0xdf6f[16]][_0xdf6f[22]],{include:[{model:List}]})[_0xdf6f[32]](function(_0x17b7x11){if(!_0x17b7x11){return _0x17b7xe[_0xdf6f[15]](401)};_0x17b7xd[_0xdf6f[16]]= _0x17b7x11;switch(_0x17b7xd[_0xdf6f[24]]){case _0xdf6f[17]:break;case _0xdf6f[18]:;case _0xdf6f[19]:;case _0xdf6f[20]:;case _0xdf6f[30]:logger[_0xdf6f[29]](_0xdf6f[21],_0x17b7xd[_0xdf6f[16]][_0xdf6f[22]],_0x17b7xd[_0xdf6f[16]][_0xdf6f[23]],_0x17b7xd[_0xdf6f[24]],_0x17b7xd[_0xdf6f[25]],_0x17b7xd[_0xdf6f[26]]?JSON[_0xdf6f[27]](_0x17b7xd[_0xdf6f[26]]):_0xdf6f[28]);break;default:logger[_0xdf6f[29]](_0xdf6f[31])};return _0x17b7xf()})[_0xdf6f[14]](function(_0x17b7x10){return _0x17b7xf(_0x17b7x10)})})}function hasModule(_0x17b7x17,_0x17b7x18){return compose()[_0xdf6f[34]](function(_0x17b7xd,_0x17b7xe,_0x17b7xf){return User[_0xdf6f[33]](_0x17b7xd[_0xdf6f[16]][_0xdf6f[22]])[_0xdf6f[32]](function(_0x17b7x11){var _0x17b7x1c=[];_0x17b7x17[_0xdf6f[56]](function(_0x17b7x1d){_0x17b7x1c[_0xdf6f[55]](_0x17b7x11[_0xdf6f[54]](_0x17b7x1d))});return Promise[_0xdf6f[57]](_0x17b7x1c)})[_0xdf6f[32]](function(_0x17b7x19){var hasModule=(_[_0xdf6f[51]](_0x17b7x19,function(_0x17b7x1a,_0x17b7x1b){return _0x17b7x1a|| _0x17b7x1b}));if(_[_0xdf6f[53]](_0x17b7x18,_0x17b7xd[_0xdf6f[16]][_0xdf6f[52]])|| hasModule){return _0x17b7xf()}else {_0x17b7xe[_0xdf6f[15]](403)}})[_0xdf6f[14]](function(_0x17b7x10){return _0x17b7xf(_0x17b7x10)})})}function hasRole(_0x17b7x1f){if(!_0x17b7x1f){throw  new Error(_0xdf6f[58])};return compose()[_0xdf6f[34]](isAuthenticated())[_0xdf6f[34]](function _0x17b7x20(_0x17b7xd,_0x17b7xe,_0x17b7xf){if(config[_0xdf6f[60]][_0xdf6f[59]](_0x17b7xd[_0xdf6f[16]][_0xdf6f[52]])>= config[_0xdf6f[60]][_0xdf6f[59]](_0x17b7x1f)){return _0x17b7xf()}else {return _0x17b7xe[_0xdf6f[15]](403)}})}function signToken(_0x17b7x22,_0x17b7x23,_0x17b7x24){var _0x17b7x25=60* 24* 365* 5;if(!_0x17b7x24){_0x17b7x25= _0xdf6f[61]};return jwt[_0xdf6f[62]]({id:_0x17b7x22},config[_0xdf6f[10]][_0xdf6f[9]],{expiresIn:_0x17b7x25})}function setTokenCookie(_0x17b7xd,_0x17b7xe){if(!_0x17b7xd[_0xdf6f[16]]){return _0x17b7xe[_0xdf6f[64]](404,{message:_0xdf6f[63]})};var _0x17b7x27=signToken(_0x17b7xd[_0xdf6f[16]][_0xdf6f[22]],_0x17b7xd[_0xdf6f[16]][_0xdf6f[52]]);_0x17b7xe[_0xdf6f[66]](_0xdf6f[65],JSON[_0xdf6f[27]](_0x17b7x27));_0x17b7xe[_0xdf6f[68]](_0xdf6f[67])}exports[_0xdf6f[69]]= isAuthenticated;exports[_0xdf6f[70]]= hasRole;exports[_0xdf6f[54]]= hasModule;exports[_0xdf6f[71]]= signToken;exports[_0xdf6f[72]]= setTokenCookie
\ No newline at end of file