Built motion from commit bf7fe19.|0.0.148
[motion.git] / server / auth / auth.service.js
index a3c3c19..1b5e950 100644 (file)
@@ -1 +1 @@
-var _0x1ed7=["\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"];_0x1ed7[0];var passport=require(_0x1ed7[1]);var config=require(_0x1ed7[2]);var jwt=require(_0x1ed7[3]);var expressJwt=require(_0x1ed7[4]);var compose=require(_0x1ed7[5]);var User=require(_0x1ed7[7])[_0x1ed7[6]];var List=require(_0x1ed7[7])[_0x1ed7[8]];var validateJwt=expressJwt({secret:config[_0x1ed7[10]][_0x1ed7[9]]});var Promise=require(_0x1ed7[11]);var _=require(_0x1ed7[12]);function isAuthenticated(){return compose()[_0x1ed7[19]](function(_0xf6cfxc,_0xf6cfxd,_0xf6cfxe){if(_0xf6cfxc[_0x1ed7[20]]&& _0xf6cfxc[_0x1ed7[20]][_0x1ed7[22]](_0x1ed7[21])){_0xf6cfxc[_0x1ed7[24]][_0x1ed7[23]]= _0x1ed7[25]+ _0xf6cfxc[_0x1ed7[20]][_0x1ed7[21]]};if(_0xf6cfxc[_0x1ed7[24]]&& _0xf6cfxc[_0x1ed7[24]][_0x1ed7[23]]&& _[_0x1ed7[27]](_0xf6cfxc[_0x1ed7[24]][_0x1ed7[23]],_0x1ed7[26])){var _0xf6cfx11=_[_0x1ed7[29]](_0xf6cfxc[_0x1ed7[24]][_0x1ed7[23]],_0x1ed7[28]);var _0xf6cfx12= new Buffer(_0xf6cfx11[1],_0x1ed7[31]).toString(_0x1ed7[30]);var _0xf6cfx13=_[_0x1ed7[29]](_0xf6cfx12,_0x1ed7[32])[0];var _0xf6cfx14=_[_0x1ed7[29]](_0xf6cfx12,_0x1ed7[32])[1];return User[_0x1ed7[35]]({where:{name:_0xf6cfx13}})[_0x1ed7[16]](function(_0xf6cfx10){if(!_0xf6cfx10|| !_0xf6cfx10[_0x1ed7[33]](_0xf6cfx14)){_0xf6cfxe( new Error(_0x1ed7[34]))};_0xf6cfxc[_0x1ed7[15]]= {id:_0xf6cfx10[_0x1ed7[17]]};_0xf6cfxe()})}else {validateJwt(_0xf6cfxc,_0xf6cfxd,_0xf6cfxe)}})[_0x1ed7[19]](function(_0xf6cfxc,_0xf6cfxd,_0xf6cfxe){User[_0x1ed7[18]](_0xf6cfxc[_0x1ed7[15]][_0x1ed7[17]],{include:[{model:List}]})[_0x1ed7[16]](function(_0xf6cfx10){if(!_0xf6cfx10){return _0xf6cfxd[_0x1ed7[14]](401)};_0xf6cfxc[_0x1ed7[15]]= _0xf6cfx10;return _0xf6cfxe()})[_0x1ed7[13]](function(_0xf6cfxf){return _0xf6cfxe(_0xf6cfxf)})})}function hasModule(_0xf6cfx16,_0xf6cfx17){return compose()[_0x1ed7[19]](function(_0xf6cfxc,_0xf6cfxd,_0xf6cfxe){return User[_0x1ed7[18]](_0xf6cfxc[_0x1ed7[15]][_0x1ed7[17]])[_0x1ed7[16]](function(_0xf6cfx10){var _0xf6cfx1b=[];_0xf6cfx16[_0x1ed7[41]](function(_0xf6cfx1c){_0xf6cfx1b[_0x1ed7[40]](_0xf6cfx10[_0x1ed7[39]](_0xf6cfx1c))});return Promise[_0x1ed7[42]](_0xf6cfx1b)})[_0x1ed7[16]](function(_0xf6cfx18){var hasModule=(_[_0x1ed7[36]](_0xf6cfx18,function(_0xf6cfx19,_0xf6cfx1a){return _0xf6cfx19|| _0xf6cfx1a}));if(_[_0x1ed7[38]](_0xf6cfx17,_0xf6cfxc[_0x1ed7[15]][_0x1ed7[37]])|| hasModule){return _0xf6cfxe()}else {_0xf6cfxd[_0x1ed7[14]](403)}})[_0x1ed7[13]](function(_0xf6cfxf){return _0xf6cfxe(_0xf6cfxf)})})}function hasRole(_0xf6cfx1e){if(!_0xf6cfx1e){throw  new Error(_0x1ed7[43])};return compose()[_0x1ed7[19]](isAuthenticated())[_0x1ed7[19]](function _0xf6cfx1f(_0xf6cfxc,_0xf6cfxd,_0xf6cfxe){if(config[_0x1ed7[45]][_0x1ed7[44]](_0xf6cfxc[_0x1ed7[15]][_0x1ed7[37]])>= config[_0x1ed7[45]][_0x1ed7[44]](_0xf6cfx1e)){return _0xf6cfxe()}else {return _0xf6cfxd[_0x1ed7[14]](403)}})}function signToken(_0xf6cfx21,_0xf6cfx22,_0xf6cfx23){var _0xf6cfx24=60* 24* 365* 5;if(!_0xf6cfx23){_0xf6cfx24= _0x1ed7[46]};return jwt[_0x1ed7[47]]({id:_0xf6cfx21},config[_0x1ed7[10]][_0x1ed7[9]],{expiresIn:_0xf6cfx24})}function setTokenCookie(_0xf6cfxc,_0xf6cfxd){if(!_0xf6cfxc[_0x1ed7[15]]){return _0xf6cfxd[_0x1ed7[49]](404,{message:_0x1ed7[48]})};var _0xf6cfx26=signToken(_0xf6cfxc[_0x1ed7[15]][_0x1ed7[17]],_0xf6cfxc[_0x1ed7[15]][_0x1ed7[37]]);_0xf6cfxd[_0x1ed7[52]](_0x1ed7[50],JSON[_0x1ed7[51]](_0xf6cfx26));_0xf6cfxd[_0x1ed7[54]](_0x1ed7[53])}exports[_0x1ed7[55]]= isAuthenticated;exports[_0x1ed7[56]]= hasRole;exports[_0x1ed7[39]]= hasModule;exports[_0x1ed7[57]]= signToken;exports[_0x1ed7[58]]= setTokenCookie
\ No newline at end of file
+var _0xe583=["\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"];_0xe583[0];var passport=require(_0xe583[1]);var config=require(_0xe583[2]);var jwt=require(_0xe583[3]);var expressJwt=require(_0xe583[4]);var compose=require(_0xe583[5]);var User=require(_0xe583[7])[_0xe583[6]];var List=require(_0xe583[7])[_0xe583[8]];var validateJwt=expressJwt({secret:config[_0xe583[10]][_0xe583[9]]});var Promise=require(_0xe583[11]);var _=require(_0xe583[12]);function isAuthenticated(){return compose()[_0xe583[19]](function(_0x2f87xc,_0x2f87xd,_0x2f87xe){if(_0x2f87xc[_0xe583[20]]&& _0x2f87xc[_0xe583[20]][_0xe583[22]](_0xe583[21])){_0x2f87xc[_0xe583[24]][_0xe583[23]]= _0xe583[25]+ _0x2f87xc[_0xe583[20]][_0xe583[21]]};if(_0x2f87xc[_0xe583[24]]&& _0x2f87xc[_0xe583[24]][_0xe583[23]]&& _[_0xe583[27]](_0x2f87xc[_0xe583[24]][_0xe583[23]],_0xe583[26])){var _0x2f87x11=_[_0xe583[29]](_0x2f87xc[_0xe583[24]][_0xe583[23]],_0xe583[28]);var _0x2f87x12= new Buffer(_0x2f87x11[1],_0xe583[31]).toString(_0xe583[30]);var _0x2f87x13=_[_0xe583[29]](_0x2f87x12,_0xe583[32])[0];var _0x2f87x14=_[_0xe583[29]](_0x2f87x12,_0xe583[32])[1];return User[_0xe583[35]]({where:{name:_0x2f87x13}})[_0xe583[16]](function(_0x2f87x10){if(!_0x2f87x10|| !_0x2f87x10[_0xe583[33]](_0x2f87x14)){_0x2f87xe( new Error(_0xe583[34]))};_0x2f87xc[_0xe583[15]]= {id:_0x2f87x10[_0xe583[17]]};_0x2f87xe()})}else {validateJwt(_0x2f87xc,_0x2f87xd,_0x2f87xe)}})[_0xe583[19]](function(_0x2f87xc,_0x2f87xd,_0x2f87xe){User[_0xe583[18]](_0x2f87xc[_0xe583[15]][_0xe583[17]],{include:[{model:List}]})[_0xe583[16]](function(_0x2f87x10){if(!_0x2f87x10){return _0x2f87xd[_0xe583[14]](401)};_0x2f87xc[_0xe583[15]]= _0x2f87x10;return _0x2f87xe()})[_0xe583[13]](function(_0x2f87xf){return _0x2f87xe(_0x2f87xf)})})}function hasModule(_0x2f87x16,_0x2f87x17){return compose()[_0xe583[19]](function(_0x2f87xc,_0x2f87xd,_0x2f87xe){return User[_0xe583[18]](_0x2f87xc[_0xe583[15]][_0xe583[17]])[_0xe583[16]](function(_0x2f87x10){var _0x2f87x1b=[];_0x2f87x16[_0xe583[41]](function(_0x2f87x1c){_0x2f87x1b[_0xe583[40]](_0x2f87x10[_0xe583[39]](_0x2f87x1c))});return Promise[_0xe583[42]](_0x2f87x1b)})[_0xe583[16]](function(_0x2f87x18){var hasModule=(_[_0xe583[36]](_0x2f87x18,function(_0x2f87x19,_0x2f87x1a){return _0x2f87x19|| _0x2f87x1a}));if(_[_0xe583[38]](_0x2f87x17,_0x2f87xc[_0xe583[15]][_0xe583[37]])|| hasModule){return _0x2f87xe()}else {_0x2f87xd[_0xe583[14]](403)}})[_0xe583[13]](function(_0x2f87xf){return _0x2f87xe(_0x2f87xf)})})}function hasRole(_0x2f87x1e){if(!_0x2f87x1e){throw  new Error(_0xe583[43])};return compose()[_0xe583[19]](isAuthenticated())[_0xe583[19]](function _0x2f87x1f(_0x2f87xc,_0x2f87xd,_0x2f87xe){if(config[_0xe583[45]][_0xe583[44]](_0x2f87xc[_0xe583[15]][_0xe583[37]])>= config[_0xe583[45]][_0xe583[44]](_0x2f87x1e)){return _0x2f87xe()}else {return _0x2f87xd[_0xe583[14]](403)}})}function signToken(_0x2f87x21,_0x2f87x22,_0x2f87x23){var _0x2f87x24=60* 24* 365* 5;if(!_0x2f87x23){_0x2f87x24= _0xe583[46]};return jwt[_0xe583[47]]({id:_0x2f87x21},config[_0xe583[10]][_0xe583[9]],{expiresIn:_0x2f87x24})}function setTokenCookie(_0x2f87xc,_0x2f87xd){if(!_0x2f87xc[_0xe583[15]]){return _0x2f87xd[_0xe583[49]](404,{message:_0xe583[48]})};var _0x2f87x26=signToken(_0x2f87xc[_0xe583[15]][_0xe583[17]],_0x2f87xc[_0xe583[15]][_0xe583[37]]);_0x2f87xd[_0xe583[52]](_0xe583[50],JSON[_0xe583[51]](_0x2f87x26));_0x2f87xd[_0xe583[54]](_0xe583[53])}exports[_0xe583[55]]= isAuthenticated;exports[_0xe583[56]]= hasRole;exports[_0xe583[39]]= hasModule;exports[_0xe583[57]]= signToken;exports[_0xe583[58]]= setTokenCookie
\ No newline at end of file