'use strict';function _0x5915(_0x5c14a7,_0xd5a8a6){const _0x5a2be1=_0x5a2b();return _0x5915=function(_0x591512,_0x85cd7f){_0x591512=_0x591512-0x1b6;let _0x5683d2=_0x5a2be1[_0x591512];return _0x5683d2;},_0x5915(_0x5c14a7,_0xd5a8a6);}const _0x37e3f0=_0x5915;(function(_0x4f9c84,_0xc594e3){const _0x1e3a58=_0x5915,_0x4e4f4c=_0x4f9c84();while(!![]){try{const _0x41617a=-parseInt(_0x1e3a58(0x1fe))/0x1+-parseInt(_0x1e3a58(0x224))/0x2*(parseInt(_0x1e3a58(0x1ce))/0x3)+parseInt(_0x1e3a58(0x1dd))/0x4*(parseInt(_0x1e3a58(0x1f5))/0x5)+parseInt(_0x1e3a58(0x22e))/0x6+parseInt(_0x1e3a58(0x225))/0x7+parseInt(_0x1e3a58(0x1e5))/0x8*(parseInt(_0x1e3a58(0x1bf))/0x9)+-parseInt(_0x1e3a58(0x1e1))/0xa;if(_0x41617a===_0xc594e3)break;else _0x4e4f4c['push'](_0x4e4f4c['shift']());}catch(_0x3b41c6){_0x4e4f4c['push'](_0x4e4f4c['shift']());}}}(_0x5a2b,0xa86a6));var __decorate=this&&this[_0x37e3f0(0x1bd)]||function(_0x2b962b,_0x1a0c18,_0x22b735,_0x51ec58){const _0x59daa3=_0x37e3f0;var _0x3f8fba=arguments[_0x59daa3(0x209)],_0xae05=_0x3f8fba<0x3?_0x1a0c18:_0x51ec58===null?_0x51ec58=Object[_0x59daa3(0x207)](_0x1a0c18,_0x22b735):_0x51ec58,_0x3a7c6c;if(typeof Reflect===_0x59daa3(0x236)&&typeof Reflect[_0x59daa3(0x1c7)]==='function')_0xae05=Reflect[_0x59daa3(0x1c7)](_0x2b962b,_0x1a0c18,_0x22b735,_0x51ec58);else{for(var _0x5e98c0=_0x2b962b[_0x59daa3(0x209)]-0x1;_0x5e98c0>=0x0;_0x5e98c0--)if(_0x3a7c6c=_0x2b962b[_0x5e98c0])_0xae05=(_0x3f8fba<0x3?_0x3a7c6c(_0xae05):_0x3f8fba>0x3?_0x3a7c6c(_0x1a0c18,_0x22b735,_0xae05):_0x3a7c6c(_0x1a0c18,_0x22b735))||_0xae05;}return _0x3f8fba>0x3&&_0xae05&&Object[_0x59daa3(0x20b)](_0x1a0c18,_0x22b735,_0xae05),_0xae05;},__metadata=this&&this[_0x37e3f0(0x1f6)]||function(_0x26f43c,_0x34aaba){const _0x4b33cc=_0x37e3f0;if(typeof Reflect===_0x4b33cc(0x236)&&typeof Reflect[_0x4b33cc(0x1db)]===_0x4b33cc(0x1cf))return Reflect[_0x4b33cc(0x1db)](_0x26f43c,_0x34aaba);},__param=this&&this[_0x37e3f0(0x218)]||function(_0x47190d,_0x12b0d1){return function(_0x5b0e13,_0x4c2fd7){_0x12b0d1(_0x5b0e13,_0x4c2fd7,_0x47190d);};};Object[_0x37e3f0(0x20b)](exports,'__esModule',{'value':!![]}),exports[_0x37e3f0(0x1bc)]=void 0x0;const globalConfig_service_1=require(_0x37e3f0(0x1b7)),verification_constant_1=require(_0x37e3f0(0x21b)),verification_service_1=require('../verification/verification.service'),common_1=require('@nestjs/common'),jwt_1=require('@nestjs/jwt'),user_service_1=require(_0x37e3f0(0x1d3)),mailer_service_1=require(_0x37e3f0(0x1d5)),user_constant_1=require('../../common/constants/user.constant'),userBalance_service_1=require(_0x37e3f0(0x1ed)),config_entity_1=require(_0x37e3f0(0x217)),typeorm_1=require(_0x37e3f0(0x20a)),typeorm_2=require(_0x37e3f0(0x23e)),utils_1=require('../../common/utils'),os=require('os'),redisCache_service_1=require(_0x37e3f0(0x1c6)),svgCaptcha=require(_0x37e3f0(0x1e7)),bcrypt=require(_0x37e3f0(0x1bb));let AuthService=class AuthService{constructor(_0x3e3437,_0x5617e3,_0x4a66f6,_0x5e91ff,_0x34a2b5,_0x14c239,_0x1cb63d,_0x875ce8){const _0x157082=_0x37e3f0;this[_0x157082(0x239)]=_0x3e3437,this['userService']=_0x5617e3,this['jwtService']=_0x4a66f6,this[_0x157082(0x227)]=_0x5e91ff,this[_0x157082(0x1d9)]=_0x34a2b5,this[_0x157082(0x1d6)]=_0x14c239,this[_0x157082(0x21a)]=_0x1cb63d,this[_0x157082(0x21d)]=_0x875ce8;}async[_0x37e3f0(0x21f)](){const _0x5023d7=_0x37e3f0;this[_0x5023d7(0x1c2)]();}async[_0x37e3f0(0x228)](_0x50ab40,_0xdf4040){const _0x45145c=_0x37e3f0;await this['verificationService']['verifyCaptcha'](_0x50ab40);const _0x326c03=await this[_0x45145c(0x1c9)][_0x45145c(0x1e8)](_0x50ab40,_0xdf4040),{username:_0xe84e8f,email:_0x156cad,client:_0x4b268f,id:_0x1d09c0}=_0x326c03,_0x5a7996={'username':_0xe84e8f,'email':_0x156cad,'id':_0x1d09c0};return _0x4b268f&&(_0x5a7996[_0x45145c(0x1e0)]=_0x4b268f),_0x5a7996;}async[_0x37e3f0(0x201)](_0x2e993f,_0x5e1f76){const _0x2f97cc=_0x37e3f0,{username:_0x41f53a,password:_0x29d052,phone:_0x3251bc,phoneCode:_0x6b4f20,invitedBy:_0x10b75a}=_0x2e993f;await this[_0x2f97cc(0x1c9)][_0x2f97cc(0x220)](_0x2e993f);const _0x4f0130=await this['globalConfigService'][_0x2f97cc(0x1c1)](),_0x2e5081=_0x4f0130+_0x2f97cc(0x1f8)+_0x3251bc,_0x5d576e=await this[_0x2f97cc(0x21a)][_0x2f97cc(0x1e4)]({'key':_0x2e5081});if(!_0x5d576e)throw new common_1[(_0x2f97cc(0x230))]('验证码已过期、请重新发送!',common_1[_0x2f97cc(0x1be)][_0x2f97cc(0x1fc)]);if(_0x6b4f20!==_0x5d576e)throw new common_1[(_0x2f97cc(0x230))](_0x2f97cc(0x1c4),common_1[_0x2f97cc(0x1be)][_0x2f97cc(0x1fc)]);const _0x3943f1=(0x0,utils_1[_0x2f97cc(0x1c5)])()+'@nine.com',_0x591c99={'username':_0x41f53a,'password':_0x29d052,'phone':_0x3251bc,'invitedBy':_0x10b75a,'email':_0x3943f1,'status':user_constant_1[_0x2f97cc(0x22b)][_0x2f97cc(0x237)]},_0x2a7994=await this['globalConfigService']['getConfigs']([_0x2f97cc(0x23c)]);_0x591c99[_0x2f97cc(0x1d4)]=_0x2a7994;const _0x3cded1=bcrypt['hashSync'](_0x29d052,0xa);_0x591c99[_0x2f97cc(0x213)]=_0x3cded1;const _0x3d7220=await this[_0x2f97cc(0x1c9)]['createUser'](_0x591c99);let _0x165ef7;_0x10b75a&&(_0x165ef7=await this['userService'][_0x2f97cc(0x22d)](_0x10b75a));await this[_0x2f97cc(0x1d6)][_0x2f97cc(0x1e2)](_0x3d7220['id'],_0x165ef7===null||_0x165ef7===void 0x0?void 0x0:_0x165ef7['id']);return;}async[_0x37e3f0(0x216)](_0x411ade,_0x14cedb){const _0x1d10e5=_0x37e3f0,_0x14e01d=await this[_0x1d10e5(0x1c9)]['verifyUserCredentials'](_0x411ade),{username:_0x279bbf,id:_0x5f5278,email:_0xc1efa4,role:_0x4b57ba,openId:_0x107061,client:_0x1e334c}=_0x14e01d,_0x22f010=(0x0,utils_1[_0x1d10e5(0x1cb)])(_0x14cedb);await this[_0x1d10e5(0x1c9)][_0x1d10e5(0x1e9)](_0x5f5278,_0x22f010);const _0x100a34=await this[_0x1d10e5(0x223)]['sign']({'username':_0x279bbf,'id':_0x5f5278,'email':_0xc1efa4,'role':_0x4b57ba,'openId':_0x107061,'client':_0x1e334c});return await this['redisCacheService'][_0x1d10e5(0x211)](_0x5f5278,_0x100a34),_0x100a34;}async['loginByPhone'](_0x4c8c7c,_0x45a1bc){const _0x274ce1=_0x37e3f0,_0x2f2038=await this['userService'][_0x274ce1(0x1d2)](_0x4c8c7c),{username:_0xa9cb5f,id:_0x2b7a89,email:_0x45da93,role:_0x2ebe21,openId:_0x550e08,client:_0x5ea627}=_0x2f2038,_0x59cb32=(0x0,utils_1['getClientIp'])(_0x45a1bc);await this[_0x274ce1(0x1c9)]['savaLoginIp'](_0x2b7a89,_0x59cb32);const {phone:_0x409b71}=_0x4c8c7c,_0x2f7bfe=await this[_0x274ce1(0x223)][_0x274ce1(0x1fd)]({'username':_0xa9cb5f,'id':_0x2b7a89,'email':_0x45da93,'role':_0x2ebe21,'openId':_0x550e08,'client':_0x5ea627,'phone':_0x409b71});return await this[_0x274ce1(0x21a)][_0x274ce1(0x211)](_0x2b7a89,_0x2f7bfe),_0x2f7bfe;}async[_0x37e3f0(0x1ca)](_0x6c36c8,_0x19cc11){const _0x3aabd1=_0x37e3f0,{status:_0x3205e7}=_0x6c36c8;if(_0x3205e7!==user_constant_1[_0x3aabd1(0x22b)][_0x3aabd1(0x237)])throw new common_1[(_0x3aabd1(0x230))](user_constant_1['UserStatusErrMsg'][_0x3205e7],common_1[_0x3aabd1(0x1be)][_0x3aabd1(0x1fc)]);const {username:_0x434f68,id:_0x8df78b,email:_0x2efd8e,role:_0x28e489,openId:_0x534d48,client:_0x524e8a}=_0x6c36c8,_0x5c4748=(0x0,utils_1[_0x3aabd1(0x1cb)])(_0x19cc11);await this[_0x3aabd1(0x1c9)][_0x3aabd1(0x1e9)](_0x8df78b,_0x5c4748);const _0x17aee7=await this[_0x3aabd1(0x223)][_0x3aabd1(0x1fd)]({'username':_0x434f68,'id':_0x8df78b,'email':_0x2efd8e,'role':_0x28e489,'openId':_0x534d48,'client':_0x524e8a});return await this['redisCacheService'][_0x3aabd1(0x211)](_0x8df78b,_0x17aee7),_0x17aee7;}async[_0x37e3f0(0x1f4)](_0x5af521){const _0x45dc39=_0x37e3f0,{id:_0x4f450d}=_0x5af521[_0x45dc39(0x1cc)];return await this[_0x45dc39(0x1c9)]['getUserInfo'](_0x4f450d);}async[_0x37e3f0(0x1b9)](_0x5ad91f,_0x1c714a){const _0x41a6f2=_0x37e3f0,_0x33e434=await this[_0x41a6f2(0x239)][_0x41a6f2(0x1ea)]({'where':{'configKey':(0x0,typeorm_1['In'])([_0x41a6f2(0x1fa),_0x41a6f2(0x1ec),_0x41a6f2(0x1c8),_0x41a6f2(0x1df),_0x41a6f2(0x1b6)])}}),_0x2b81da=_0x33e434[_0x41a6f2(0x1f7)]((_0x402ce1,_0x516c75)=>{const _0x1b1715=_0x41a6f2;return _0x402ce1[_0x516c75[_0x1b1715(0x1ee)]]=_0x516c75[_0x1b1715(0x20e)],_0x402ce1;},{});try{const _0x1ebea7=await this[_0x41a6f2(0x1d9)]['verifyCode'](_0x5ad91f,verification_constant_1['VerificationEnum'][_0x41a6f2(0x1dc)]),{type:_0x5f24fa,userId:_0x483644}=_0x1ebea7;if(_0x5f24fa!==verification_constant_1[_0x41a6f2(0x1b8)]['Registration'])throw new common_1['HttpException'](_0x41a6f2(0x20f),common_1['HttpStatus'][_0x41a6f2(0x1fc)]);const _0x392b19=await this[_0x41a6f2(0x1c9)][_0x41a6f2(0x1d7)](_0x483644);if(_0x392b19===user_constant_1['UserStatusEnum']['ACTIVE'])throw new common_1[(_0x41a6f2(0x230))](_0x41a6f2(0x229),common_1['HttpStatus'][_0x41a6f2(0x1fc)]);await this[_0x41a6f2(0x1c9)][_0x41a6f2(0x205)](_0x1ebea7['userId'],user_constant_1[_0x41a6f2(0x22b)][_0x41a6f2(0x237)]);const _0x3eaaea=await this['userService'][_0x41a6f2(0x208)](_0x1ebea7[_0x41a6f2(0x222)]),{username:_0x5ad982,email:_0x1ac524,id:_0x10dec3,invitedBy:_0x337747}=_0x3eaaea;let _0x16cbb2;_0x337747&&(_0x16cbb2=await this[_0x41a6f2(0x1c9)][_0x41a6f2(0x22d)](_0x337747)),await this[_0x41a6f2(0x1d6)]['addBalanceToNewUser'](_0x10dec3,_0x16cbb2===null||_0x16cbb2===void 0x0?void 0x0:_0x16cbb2['id']),_0x1c714a['redirect'](_0x41a6f2(0x238)+_0x10dec3[_0x41a6f2(0x235)]()['padStart'](0x4,'0')+'&username='+_0x5ad982+_0x41a6f2(0x203)+_0x1ac524+_0x41a6f2(0x1f1)+_0x2b81da[_0x41a6f2(0x1fa)]+_0x41a6f2(0x1c0)+_0x2b81da['registerSuccessEmailTeamName']+'®isterSuccessEmaileAppend='+_0x2b81da['registerSuccessEmaileAppend']);}catch(_0x4b1210){console[_0x41a6f2(0x1cd)]('error:\x20',_0x4b1210);const _0x1ea655=_0x4b1210[_0x41a6f2(0x1f9)];_0x1c714a[_0x41a6f2(0x1ef)](_0x41a6f2(0x1f0)+_0x1ea655+_0x41a6f2(0x202)+_0x2b81da[_0x41a6f2(0x1df)]+_0x41a6f2(0x21c)+_0x2b81da[_0x41a6f2(0x1b6)]);}}async[_0x37e3f0(0x219)](_0x6d6bf6,_0x41915c){const _0x36f13a=_0x37e3f0,{id:_0x918ff3,client:_0x4198fa,role:_0x5c8af1}=_0x6d6bf6['user'];if(_0x4198fa&&Number(_0x4198fa)>0x0)throw new common_1[(_0x36f13a(0x230))](_0x36f13a(0x1c3),common_1[_0x36f13a(0x1be)][_0x36f13a(0x1fc)]);if(_0x5c8af1===_0x36f13a(0x204))throw new common_1[(_0x36f13a(0x230))](_0x36f13a(0x221),common_1[_0x36f13a(0x1be)]['BAD_REQUEST']);const _0xc2bded=await this[_0x36f13a(0x1c9)][_0x36f13a(0x23d)](_0x918ff3,_0x41915c[_0x36f13a(0x1ba)]);if(!_0xc2bded)throw new common_1['HttpException'](_0x36f13a(0x200),common_1['HttpStatus'][_0x36f13a(0x1fc)]);return this['userService'][_0x36f13a(0x233)](_0x918ff3,_0x41915c[_0x36f13a(0x213)]),'密码修改成功';}async['updatePassByOther'](_0x2d2d7b,_0x55d082){const _0x4b146d=_0x37e3f0,{id:_0x1c00a6,client:_0x4d0ce2}=_0x2d2d7b[_0x4b146d(0x1cc)];if(!_0x4d0ce2)throw new common_1[(_0x4b146d(0x230))](_0x4b146d(0x1d8),common_1[_0x4b146d(0x1be)][_0x4b146d(0x1fc)]);return this[_0x4b146d(0x1c9)][_0x4b146d(0x233)](_0x1c00a6,_0x55d082['password']),'密码修改成功';}['getIp'](){const _0x21fe92=_0x37e3f0;let _0x5c3dfc;const _0x266f91=os[_0x21fe92(0x23b)]();Object['keys'](_0x266f91)['forEach'](_0x32abea=>{const _0x453a7a=_0x21fe92,_0x4798cc=_0x266f91[_0x32abea];for(let _0x390624=0x0;_0x390624<_0x4798cc[_0x453a7a(0x209)];_0x390624++){const _0x220265=_0x4798cc[_0x390624];if(_0x220265[_0x453a7a(0x22c)]===_0x453a7a(0x214)&&_0x220265['address']!==_0x453a7a(0x231)&&!_0x220265[_0x453a7a(0x210)]){_0x5c3dfc=_0x220265[_0x453a7a(0x1ff)];break;}}}),this[_0x21fe92(0x1eb)]=_0x5c3dfc;}async['captcha'](_0x1e3a9e){const _0xe80fd7=_0x37e3f0,_0x2e110c=await this['globalConfigService']['getNamespace'](),{color:color='#fff'}=_0x1e3a9e,_0x455b38=svgCaptcha[_0xe80fd7(0x1d0)]({'background':color,'height':0x22,'width':0x78,'noise':0x3}),_0xebc7d0=_0x455b38[_0xe80fd7(0x226)],_0x328f68=(0x0,utils_1[_0xe80fd7(0x1c5)])(),_0x1bd02c=_0x2e110c+_0xe80fd7(0x212)+_0x328f68;return await this[_0xe80fd7(0x21a)][_0xe80fd7(0x22a)]({'key':_0x1bd02c,'val':_0x455b38['text']},0x5*0x3c),{'svgCode':_0x455b38[_0xe80fd7(0x21e)],'code':_0x328f68};}async[_0x37e3f0(0x1da)](_0x462237){const _0x25d076=_0x37e3f0;await this[_0x25d076(0x1d9)][_0x25d076(0x1e6)](_0x462237);const {phone:_0x31961e}=_0x462237,_0x224008=await this['globalConfigService']['getNamespace'](),_0x8e0567=_0x224008+_0x25d076(0x1f8)+_0x31961e,_0x135839=await this[_0x25d076(0x21a)][_0x25d076(0x1de)](_0x8e0567);if(_0x135839&&_0x135839>0x0)throw new common_1[(_0x25d076(0x230))](_0x135839+_0x25d076(0x23f),common_1[_0x25d076(0x1be)][_0x25d076(0x1fc)]);const _0x71d679=(0x0,utils_1['createRandomCode'])(),_0xce6c8f={'phone':_0x31961e,'code':_0x71d679};return await this[_0x25d076(0x1d9)][_0x25d076(0x1da)](_0xce6c8f),await this[_0x25d076(0x21a)][_0x25d076(0x22a)]({'key':_0x8e0567,'val':_0x71d679},0x1*0x3c),_0x25d076(0x206);}[_0x37e3f0(0x232)](_0x446ad7){const _0x33c693=_0x37e3f0,_0x23f211=this['jwtService'][_0x33c693(0x1fd)]({'username':'游客'+_0x446ad7,'id':_0x446ad7,'email':_0x446ad7+_0x33c693(0x234),'role':_0x33c693(0x23a),'openId':null,'client':null});return _0x23f211;}};AuthService=__decorate([(0x0,common_1[_0x37e3f0(0x20d)])(),__param(0x0,(0x0,typeorm_2['InjectRepository'])(config_entity_1[_0x37e3f0(0x1fb)])),__metadata(_0x37e3f0(0x1f3),[typeorm_1[_0x37e3f0(0x1e3)],user_service_1[_0x37e3f0(0x20c)],jwt_1[_0x37e3f0(0x215)],mailer_service_1[_0x37e3f0(0x22f)],verification_service_1[_0x37e3f0(0x1f2)],userBalance_service_1['UserBalanceService'],redisCache_service_1[_0x37e3f0(0x1d1)],globalConfig_service_1['GlobalConfigService']])],AuthService),exports[_0x37e3f0(0x1bc)]=AuthService;function _0x5a2b(){const _0x3eb478=['mailerService','register','账户已被激活过','set','UserStatusEnum','family','qureyUserInfoByInviteCode','2778516XPBBsm','MailerService','HttpException','127.0.0.1','createTokenFromFingerprint','updateUserPassword','@nine.com','toString','object','ACTIVE','/api/auth/registerSuccess?id=','configEntity','visitor','networkInterfaces','userDefautlAvatar','verifyUserPassword','@nestjs/typeorm','秒内不得重复发送短信!','registerFailEmailTeamName','../globalConfig/globalConfig.service','VerificationEnum','activateAccount','oldPassword','bcryptjs','AuthService','__decorate','HttpStatus','9SSzDuI','®isterSuccessEmailTeamName=','getNamespace','getIp','无权此操作、请联系管理员!','验证码填写错误、请重新输入!','createRandomUid','../redisCache/redisCache.service','decorate','registerSuccessEmaileAppend','userService','loginByOpenId','getClientIp','user','log','2058009ZyRzBx','function','createMathExpr','RedisCacheService','verifyUserCredentials','../user/user.service','avatar','../mailer/mailer.service','userBalanceService','getUserStatus','无权此操作!','verificationService','sendPhoneCode','metadata','Registration','4759516VqjTli','ttl','registerFailEmailTitle','client','4219820XoElGt','addBalanceToNewUser','Repository','get','8233864uRIcVG','verifyCaptcha','svg-captcha','createUserAndVerifycation','savaLoginIp','find','ipAddress','registerSuccessEmailTeamName','../userBalance/userBalance.service','configKey','redirect','/api/auth/registerError?message=','®isterSuccessEmailTitle=','VerificationService','design:paramtypes','getInfo','5rWHZmX','__metadata','reduce',':PHONECODE:','response','registerSuccessEmailTitle','ConfigEntity','BAD_REQUEST','sign','1165668ysqOLd','address','旧密码错误、请检查提交','registerByPhone','®isterFailEmailTitle=','&email=','admin','updateUserStatus','验证码发送成功、请填写验证码完成注册!','getOwnPropertyDescriptor','queryUserInfoById','length','typeorm','defineProperty','UserService','Injectable','configVal','验证码类型错误','internal','saveToken',':CAPTCHA:','password','IPv4','JwtService','login','../globalConfig/config.entity','__param','updatePassword','redisCacheService','../../common/constants/verification.constant','®isterFailEmailTeamName=','globalConfigService','data','onModuleInit','verifyUserRegisterByPhone','非法操作、请联系管理员!','userId','jwtService','4fRSEgG','6771016isJkLk','text'];_0x5a2b=function(){return _0x3eb478;};return _0x5a2b();}