Built motion from commit 42b6453.|2.0.26
[motion2.git] / server / api / authLocal / authLocal.controller.js
1 var _0xd77c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x75\x74\x69\x6C","\x70\x61\x73\x73\x70\x6F\x72\x74","\x53\x74\x72\x61\x74\x65\x67\x79","\x70\x61\x73\x73\x70\x6F\x72\x74\x2D\x6C\x6F\x63\x61\x6C","\x62\x6C\x75\x65\x62\x69\x72\x64","\x64\x62","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x79\x73\x71\x6C\x64\x62","\x73\x69\x67\x6E\x54\x6F\x6B\x65\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6D\x70\x6F\x6E\x65\x6E\x74\x73\x2F\x61\x75\x74\x68\x2F\x73\x65\x72\x76\x69\x63\x65","\x72\x6F\x6C\x65","\x61\x67\x65\x6E\x74","\x63\x61\x74\x63\x68","\x61\x67\x65\x6E\x74\x73","\x4D\x61\x78\x69\x6D\x75\x6D\x20\x6C\x6F\x67\x69\x6E\x20\x68\x61\x73\x20\x62\x65\x65\x6E\x20\x72\x65\x61\x63\x68\x65\x64","\x74\x68\x65\x6E","\x67\x65\x74\x4C\x69\x63\x65\x6E\x73\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x69\x63\x65\x6E\x73\x65\x2F\x75\x74\x69\x6C","\x69\x64","\x63\x6F\x75\x6E\x74","\x55\x73\x65\x72","\x54\x68\x69\x73\x20\x70\x61\x73\x73\x77\x6F\x72\x64\x20\x69\x73\x20\x6E\x6F\x74\x20\x63\x6F\x72\x72\x65\x63\x74\x2E","\x61\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65","\x54\x68\x69\x73\x20\x6E\x61\x6D\x65\x20\x69\x73\x20\x6E\x6F\x74\x20\x72\x65\x67\x69\x73\x74\x65\x72\x65\x64\x2E","\x74\x72\x69\x6D","\x74\x6F\x4C\x6F\x77\x65\x72\x43\x61\x73\x65","\x61\x64\x6D\x69\x6E","\x75\x73\x65\x72","\x66\x69\x6E\x64","\x6C\x6F\x67\x69\x6E","\x6C\x6F\x63\x61\x6C","\x6A\x73\x6F\x6E","\x73\x74\x61\x74\x75\x73","\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","\x6E\x61\x6D\x65","\x70\x61\x73\x73\x77\x6F\x72\x64","\x75\x73\x65"];_0xd77c[0];var util=require(_0xd77c[1]);var passport=require(_0xd77c[2]);var LocalStrategy=require(_0xd77c[4])[_0xd77c[3]];var BPromise=require(_0xd77c[5]);var db=require(_0xd77c[7])[_0xd77c[6]];var signToken=require(_0xd77c[9])[_0xd77c[8]];var getLicense=function(_0xa53dx8){return  new BPromise(function(_0xa53dx9,_0xa53dxa){var _0xa53dxb=0;_0xa53dx8[_0xd77c[10]]!== _0xd77c[11]&& _0xa53dx9(_0xa53dx8);return db[_0xd77c[20]][_0xd77c[19]]({where:{role:_0xd77c[11],online:true,id:{$ne:_0xa53dx8[_0xd77c[18]]}}})[_0xd77c[15]](function(_0xa53dxe){_0xa53dxb= _0xa53dxe;return require(_0xd77c[17])[_0xd77c[16]]()})[_0xd77c[15]](function(_0xa53dxd){if(_0xa53dxd&& _0xa53dxd[_0xd77c[13]]&& _0xa53dxb>= _0xa53dxd[_0xd77c[13]]){return _0xa53dxa({message:_0xd77c[14]})};return _0xa53dx9(_0xa53dx8)})[_0xd77c[12]](function(_0xa53dxc){return _0xa53dxa(_0xa53dxc)})})};function localAuthenticate(_0xa53dx10,_0xa53dx11,_0xa53dx12,_0xa53dx13){var _0xa53dx14;_0xa53dx10[_0xd77c[28]]({where:{name:_0xa53dx11[_0xd77c[25]]()[_0xd77c[24]](),role:{$or:[_0xd77c[26],_0xd77c[27],_0xd77c[11]]}}})[_0xd77c[15]](function(_0xa53dx8){if(!_0xa53dx8){return _0xa53dx13(null,false,{message:_0xd77c[23]})};return getLicense(_0xa53dx8)})[_0xd77c[15]](function(_0xa53dx8){_0xa53dx8[_0xd77c[22]](_0xa53dx12,function(_0xa53dx15,_0xa53dx16){if(_0xa53dx15){return _0xa53dx13(_0xa53dx15)};if(!_0xa53dx16){return _0xa53dx13(null,false,{message:_0xd77c[21]})}else {return _0xa53dx13(null,_0xa53dx8)}})})[_0xd77c[12]](function(_0xa53dxc){_0xa53dx13(_0xa53dxc)})}exports[_0xd77c[29]]= function(_0xa53dx17,_0xa53dx18,_0xa53dx19){passport[_0xd77c[22]](_0xd77c[30],function(_0xa53dxc,_0xa53dx8,_0xa53dx1a){var _0xa53dx1b=_0xa53dxc|| _0xa53dx1a;if(_0xa53dx1b){return _0xa53dx18[_0xd77c[32]](401)[_0xd77c[31]](_0xa53dx1b)};if(!_0xa53dx8){return _0xa53dx18[_0xd77c[32]](404)[_0xd77c[31]]({message:_0xd77c[33]})};var _0xa53dx1c=signToken(_0xa53dx8[_0xd77c[18]],_0xa53dx8[_0xd77c[10]]);_0xa53dx18[_0xd77c[31]]({id:_0xa53dx8[_0xd77c[18]],token:_0xa53dx1c})})(_0xa53dx17,_0xa53dx18,_0xa53dx19)};passport[_0xd77c[36]]( new LocalStrategy({usernameField:_0xd77c[34],passwordField:_0xd77c[35]},function(_0xa53dx11,_0xa53dx12,_0xa53dx13){return localAuthenticate(db.User,_0xa53dx11,_0xa53dx12,_0xa53dx13)}))