mirror of
https://github.com/vastxie/99AI.git
synced 2025-11-13 04:03:45 +08:00
NineAI 2.4.2
This commit is contained in:
187
dist/modules/auth/auth.controller.js
vendored
Normal file
187
dist/modules/auth/auth.controller.js
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthController = void 0;
|
||||
const verifyCode_dto_1 = require("./../verification/dto/verifyCode.dto");
|
||||
const authLogin_dto_1 = require("./dto/authLogin.dto");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const jwtAuth_guard_1 = require("../../common/auth/jwtAuth.guard");
|
||||
const auth_service_1 = require("./auth.service");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const authRegister_dto_1 = require("./dto/authRegister.dto");
|
||||
const updatePassword_dto_1 = require("./dto/updatePassword.dto");
|
||||
const updatePassByOther_dto_1 = require("./dto/updatePassByOther.dto");
|
||||
const sendPhoneCode_dto_1 = require("./dto/sendPhoneCode.dto");
|
||||
const userRegisterByPhone_dto_1 = require("./dto/userRegisterByPhone.dto");
|
||||
const loginByPhone_dt_1 = require("./dto/loginByPhone.dt");
|
||||
let AuthController = class AuthController {
|
||||
constructor(authService) {
|
||||
this.authService = authService;
|
||||
}
|
||||
async register(body, req) {
|
||||
return await this.authService.register(body, req);
|
||||
}
|
||||
async registerByPhone(body, req) {
|
||||
return await this.authService.registerByPhone(body, req);
|
||||
}
|
||||
async login(body, req) {
|
||||
return this.authService.login(body, req);
|
||||
}
|
||||
async loginByPhone(body, req) {
|
||||
return this.authService.loginByPhone(body, req);
|
||||
}
|
||||
async updatePassword(req, body) {
|
||||
return this.authService.updatePassword(req, body);
|
||||
}
|
||||
async updatePassByOther(req, body) {
|
||||
return this.authService.updatePassByOther(req, body);
|
||||
}
|
||||
async getInfo(req) {
|
||||
return this.authService.getInfo(req);
|
||||
}
|
||||
async activateAccount(parmas, res) {
|
||||
return this.authService.activateAccount(parmas, res);
|
||||
}
|
||||
async registerSuccess(parmas) {
|
||||
const { username, id, email, teamName, registerSuccessEmailTitle, registerSuccessEmailTeamName, registerSuccessEmaileAppend } = parmas;
|
||||
return { username, id, email, teamName, registerSuccessEmailTitle, registerSuccessEmailTeamName, registerSuccessEmaileAppend };
|
||||
}
|
||||
async registerError(parmas) {
|
||||
const { message, teamName, registerFailEmailTitle, registerFailEmailTeamName } = parmas;
|
||||
return { message, teamName, registerFailEmailTitle, registerFailEmailTeamName };
|
||||
}
|
||||
async captcha(parmas) {
|
||||
return this.authService.captcha(parmas);
|
||||
}
|
||||
async sendPhoneCode(parmas) {
|
||||
return this.authService.sendPhoneCode(parmas);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Post)('register'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '用户注册' }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [authRegister_dto_1.UserRegisterDto, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "register", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('registerByPhone'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '用户通过手机号注册' }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [userRegisterByPhone_dto_1.UserRegisterByPhoneDto, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "registerByPhone", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('login'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '用户登录' }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [authLogin_dto_1.UserLoginDto, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "login", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('loginByPhone'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '用户手机号登录' }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [loginByPhone_dt_1.LoginByPhoneDto, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "loginByPhone", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('updatePassword'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '用户更改密码' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, updatePassword_dto_1.UpdatePasswordDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "updatePassword", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('updatePassByOther'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '用户更改密码' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, updatePassByOther_dto_1.UpdatePassByOtherDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "updatePassByOther", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('getInfo'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '获取用户个人信息' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "getInfo", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('activateAccount'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '账户激活' }),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__param(1, (0, common_1.Res)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [verifyCode_dto_1.VerifyCodeDto, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "activateAccount", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('registerSuccess'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '注册成功页面' }),
|
||||
(0, common_1.Render)('registerSuccess'),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "registerSuccess", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('registerError'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '注册失败页面' }),
|
||||
(0, common_1.Render)('registerError'),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "registerError", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('captcha'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '获取一个图形验证码' }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "captcha", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('sendPhoneCode'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '发送手机验证码' }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [sendPhoneCode_dto_1.SendPhoneCodeDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "sendPhoneCode", null);
|
||||
AuthController = __decorate([
|
||||
(0, swagger_1.ApiTags)('auth'),
|
||||
(0, common_1.Controller)('auth'),
|
||||
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
||||
], AuthController);
|
||||
exports.AuthController = AuthController;
|
||||
72
dist/modules/auth/auth.module.js
vendored
Normal file
72
dist/modules/auth/auth.module.js
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthModule = void 0;
|
||||
const verifycation_entity_1 = require("./../verification/verifycation.entity");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const verification_service_1 = require("./../verification/verification.service");
|
||||
const mailer_service_1 = require("../mailer/mailer.service");
|
||||
const nestjs_config_1 = require("nestjs-config");
|
||||
const auth_controller_1 = require("./auth.controller");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const auth_service_1 = require("./auth.service");
|
||||
const user_module_1 = require("../user/user.module");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
const jwt_1 = require("@nestjs/jwt");
|
||||
const jwt_strategy_1 = require("../../common/auth/jwt.strategy");
|
||||
const jwtAuth_guard_1 = require("../../common/auth/jwtAuth.guard");
|
||||
const userBalance_service_1 = require("../userBalance/userBalance.service");
|
||||
const balance_entity_1 = require("../userBalance/balance.entity");
|
||||
const accountLog_entity_1 = require("../userBalance/accountLog.entity");
|
||||
const config_entity_1 = require("../globalConfig/config.entity");
|
||||
const cramiPackage_entity_1 = require("../crami/cramiPackage.entity");
|
||||
const redisCache_service_1 = require("../redisCache/redisCache.service");
|
||||
const redisCache_module_1 = require("../redisCache/redisCache.module");
|
||||
const userBalance_entity_1 = require("../userBalance/userBalance.entity");
|
||||
const salesUsers_entity_1 = require("../sales/salesUsers.entity");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const whiteList_entity_1 = require("../chatgpt/whiteList.entity");
|
||||
const fingerprint_entity_1 = require("../userBalance/fingerprint.entity");
|
||||
const chatLog_entity_1 = require("../chatLog/chatLog.entity");
|
||||
const chatGroup_entity_1 = require("../chatGroup/chatGroup.entity");
|
||||
const midjourney_entity_1 = require("../midjourney/midjourney.entity");
|
||||
let AuthModule = class AuthModule {
|
||||
};
|
||||
AuthModule = __decorate([
|
||||
(0, common_1.Global)(),
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
user_module_1.UserModule,
|
||||
passport_1.PassportModule.register({ defaultStrategy: 'jwt' }),
|
||||
jwt_1.JwtModule.registerAsync({
|
||||
useFactory: async (configService) => configService.get('jwt'),
|
||||
inject: [nestjs_config_1.ConfigService],
|
||||
}),
|
||||
typeorm_1.TypeOrmModule.forFeature([
|
||||
verifycation_entity_1.VerifycationEntity,
|
||||
balance_entity_1.BalanceEntity,
|
||||
accountLog_entity_1.AccountLogEntity,
|
||||
config_entity_1.ConfigEntity,
|
||||
cramiPackage_entity_1.CramiPackageEntity,
|
||||
redisCache_module_1.RedisCacheModule,
|
||||
userBalance_entity_1.UserBalanceEntity,
|
||||
salesUsers_entity_1.SalesUsersEntity,
|
||||
user_entity_1.UserEntity,
|
||||
whiteList_entity_1.WhiteListEntity,
|
||||
fingerprint_entity_1.FingerprintLogEntity,
|
||||
chatLog_entity_1.ChatLogEntity,
|
||||
chatGroup_entity_1.ChatGroupEntity,
|
||||
midjourney_entity_1.MidjourneyEntity
|
||||
]),
|
||||
],
|
||||
controllers: [auth_controller_1.AuthController],
|
||||
providers: [auth_service_1.AuthService, jwt_strategy_1.JwtStrategy, jwtAuth_guard_1.JwtAuthGuard, mailer_service_1.MailerService, verification_service_1.VerificationService, userBalance_service_1.UserBalanceService, redisCache_service_1.RedisCacheService],
|
||||
exports: [auth_service_1.AuthService],
|
||||
})
|
||||
], AuthModule);
|
||||
exports.AuthModule = AuthModule;
|
||||
248
dist/modules/auth/auth.service.js
vendored
Normal file
248
dist/modules/auth/auth.service.js
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthService = void 0;
|
||||
const globalConfig_service_1 = require("../globalConfig/globalConfig.service");
|
||||
const verification_constant_1 = require("../../common/constants/verification.constant");
|
||||
const verification_service_1 = require("./../verification/verification.service");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const jwt_1 = require("@nestjs/jwt");
|
||||
const user_service_1 = require("../user/user.service");
|
||||
const mailer_service_1 = require("../mailer/mailer.service");
|
||||
const user_constant_1 = require("../../common/constants/user.constant");
|
||||
const userBalance_service_1 = require("../userBalance/userBalance.service");
|
||||
const config_entity_1 = require("../globalConfig/config.entity");
|
||||
const typeorm_1 = require("typeorm");
|
||||
const typeorm_2 = require("@nestjs/typeorm");
|
||||
const utils_1 = require("../../common/utils");
|
||||
const os = require("os");
|
||||
const redisCache_service_1 = require("../redisCache/redisCache.service");
|
||||
const svgCaptcha = require("svg-captcha");
|
||||
const bcrypt = require("bcryptjs");
|
||||
let AuthService = class AuthService {
|
||||
constructor(configEntity, userService, jwtService, mailerService, verificationService, userBalanceService, redisCacheService, globalConfigService) {
|
||||
this.configEntity = configEntity;
|
||||
this.userService = userService;
|
||||
this.jwtService = jwtService;
|
||||
this.mailerService = mailerService;
|
||||
this.verificationService = verificationService;
|
||||
this.userBalanceService = userBalanceService;
|
||||
this.redisCacheService = redisCacheService;
|
||||
this.globalConfigService = globalConfigService;
|
||||
}
|
||||
async onModuleInit() {
|
||||
this.getIp();
|
||||
}
|
||||
async register(body, req) {
|
||||
await this.verificationService.verifyCaptcha(body);
|
||||
const user = await this.userService.createUserAndVerifycation(body, req);
|
||||
const { username, email, client, id } = user;
|
||||
const res = { username, email, id };
|
||||
client && (res.client = client);
|
||||
return res;
|
||||
}
|
||||
async registerByPhone(body, req) {
|
||||
const { username, password, phone, phoneCode, invitedBy } = body;
|
||||
await this.userService.verifyUserRegisterByPhone(body);
|
||||
const nameSpace = await this.globalConfigService.getNamespace();
|
||||
const key = `${nameSpace}:PHONECODE:${phone}`;
|
||||
const redisPhoneCode = await this.redisCacheService.get({ key });
|
||||
if (!redisPhoneCode) {
|
||||
throw new common_1.HttpException('验证码已过期、请重新发送!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (phoneCode !== redisPhoneCode) {
|
||||
throw new common_1.HttpException('验证码填写错误、请重新输入!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const email = `${(0, utils_1.createRandomUid)()}@nine.com`;
|
||||
const newUser = { username, password, phone, invitedBy, email, status: user_constant_1.UserStatusEnum.ACTIVE };
|
||||
const userDefautlAvatar = await this.globalConfigService.getConfigs(['userDefautlAvatar']);
|
||||
newUser.avatar = userDefautlAvatar;
|
||||
const hashedPassword = bcrypt.hashSync(password, 10);
|
||||
newUser.password = hashedPassword;
|
||||
const u = await this.userService.createUser(newUser);
|
||||
let inviteUser;
|
||||
if (invitedBy) {
|
||||
inviteUser = await this.userService.qureyUserInfoByInviteCode(invitedBy);
|
||||
}
|
||||
await this.userBalanceService.addBalanceToNewUser(u.id, inviteUser === null || inviteUser === void 0 ? void 0 : inviteUser.id);
|
||||
return;
|
||||
}
|
||||
async login(user, req) {
|
||||
const u = await this.userService.verifyUserCredentials(user);
|
||||
const { username, id, email, role, openId, client } = u;
|
||||
const ip = (0, utils_1.getClientIp)(req);
|
||||
await this.userService.savaLoginIp(id, ip);
|
||||
const token = await this.jwtService.sign({ username, id, email, role, openId, client });
|
||||
await this.redisCacheService.saveToken(id, token);
|
||||
return token;
|
||||
}
|
||||
async loginByPhone(body, req) {
|
||||
const u = await this.userService.verifyUserCredentials(body);
|
||||
const { username, id, email, role, openId, client } = u;
|
||||
const ip = (0, utils_1.getClientIp)(req);
|
||||
await this.userService.savaLoginIp(id, ip);
|
||||
const { phone } = body;
|
||||
const token = await this.jwtService.sign({ username, id, email, role, openId, client, phone });
|
||||
await this.redisCacheService.saveToken(id, token);
|
||||
return token;
|
||||
}
|
||||
async loginByOpenId(user, req) {
|
||||
const { status } = user;
|
||||
if (status !== user_constant_1.UserStatusEnum.ACTIVE) {
|
||||
throw new common_1.HttpException(user_constant_1.UserStatusErrMsg[status], common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const { username, id, email, role, openId, client } = user;
|
||||
const ip = (0, utils_1.getClientIp)(req);
|
||||
await this.userService.savaLoginIp(id, ip);
|
||||
const token = await this.jwtService.sign({ username, id, email, role, openId, client });
|
||||
await this.redisCacheService.saveToken(id, token);
|
||||
return token;
|
||||
}
|
||||
async getInfo(req) {
|
||||
const { id } = req.user;
|
||||
return await this.userService.getUserInfo(id);
|
||||
}
|
||||
async activateAccount(params, res) {
|
||||
const emailConfigs = await this.configEntity.find({
|
||||
where: {
|
||||
configKey: (0, typeorm_1.In)([
|
||||
'registerSuccessEmailTitle',
|
||||
'registerSuccessEmailTeamName',
|
||||
'registerSuccessEmaileAppend',
|
||||
'registerFailEmailTitle',
|
||||
'registerFailEmailTeamName',
|
||||
]),
|
||||
},
|
||||
});
|
||||
const configMap = emailConfigs.reduce((pre, cur) => {
|
||||
pre[cur.configKey] = cur.configVal;
|
||||
return pre;
|
||||
}, {});
|
||||
try {
|
||||
const v = await this.verificationService.verifyCode(params, verification_constant_1.VerificationEnum.Registration);
|
||||
const { type, userId } = v;
|
||||
if (type !== verification_constant_1.VerificationEnum.Registration) {
|
||||
throw new common_1.HttpException('验证码类型错误', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const status = await this.userService.getUserStatus(userId);
|
||||
if (status === user_constant_1.UserStatusEnum.ACTIVE) {
|
||||
throw new common_1.HttpException('账户已被激活过', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
await this.userService.updateUserStatus(v.userId, user_constant_1.UserStatusEnum.ACTIVE);
|
||||
const u = await this.userService.queryUserInfoById(v.userId);
|
||||
const { username, email, id, invitedBy } = u;
|
||||
let inviteUser;
|
||||
if (invitedBy) {
|
||||
inviteUser = await this.userService.qureyUserInfoByInviteCode(invitedBy);
|
||||
}
|
||||
await this.userBalanceService.addBalanceToNewUser(id, inviteUser === null || inviteUser === void 0 ? void 0 : inviteUser.id);
|
||||
res.redirect(`/api/auth/registerSuccess?id=${id.toString().padStart(4, '0')}&username=${username}&email=${email}®isterSuccessEmailTitle=${configMap.registerSuccessEmailTitle}®isterSuccessEmailTeamName=${configMap.registerSuccessEmailTeamName}®isterSuccessEmaileAppend=${configMap.registerSuccessEmaileAppend}`);
|
||||
}
|
||||
catch (error) {
|
||||
console.log('error: ', error);
|
||||
const message = error.response;
|
||||
res.redirect(`/api/auth/registerError?message=${message}®isterFailEmailTitle=${configMap.registerFailEmailTitle}®isterFailEmailTeamName=${configMap.registerFailEmailTeamName}`);
|
||||
}
|
||||
}
|
||||
async updatePassword(req, body) {
|
||||
const { id, client, role } = req.user;
|
||||
if (client && Number(client) > 0) {
|
||||
throw new common_1.HttpException('无权此操作、请联系管理员!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (role === 'admin') {
|
||||
throw new common_1.HttpException('非法操作、请联系管理员!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const bool = await this.userService.verifyUserPassword(id, body.oldPassword);
|
||||
if (!bool) {
|
||||
throw new common_1.HttpException('旧密码错误、请检查提交', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
this.userService.updateUserPassword(id, body.password);
|
||||
return '密码修改成功';
|
||||
}
|
||||
async updatePassByOther(req, body) {
|
||||
const { id, client } = req.user;
|
||||
if (!client) {
|
||||
throw new common_1.HttpException('无权此操作!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
this.userService.updateUserPassword(id, body.password);
|
||||
return '密码修改成功';
|
||||
}
|
||||
getIp() {
|
||||
let ipAddress;
|
||||
const interfaces = os.networkInterfaces();
|
||||
Object.keys(interfaces).forEach((interfaceName) => {
|
||||
const interfaceInfo = interfaces[interfaceName];
|
||||
for (let i = 0; i < interfaceInfo.length; i++) {
|
||||
const alias = interfaceInfo[i];
|
||||
if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
|
||||
ipAddress = alias.address;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
async captcha(parmas) {
|
||||
const nameSpace = await this.globalConfigService.getNamespace();
|
||||
const { color = '#fff' } = parmas;
|
||||
const captcha = svgCaptcha.createMathExpr({ background: color, height: 34, width: 120, noise: 3 });
|
||||
const text = captcha.text;
|
||||
const randomId = (0, utils_1.createRandomUid)();
|
||||
const key = `${nameSpace}:CAPTCHA:${randomId}`;
|
||||
await this.redisCacheService.set({ key, val: captcha.text }, 5 * 60);
|
||||
return {
|
||||
svgCode: captcha.data,
|
||||
code: randomId,
|
||||
};
|
||||
}
|
||||
async sendPhoneCode(body) {
|
||||
await this.verificationService.verifyCaptcha(body);
|
||||
const { phone } = body;
|
||||
const nameSpace = await this.globalConfigService.getNamespace();
|
||||
const key = `${nameSpace}:PHONECODE:${phone}`;
|
||||
const ttl = await this.redisCacheService.ttl(key);
|
||||
if (ttl && ttl > 0) {
|
||||
throw new common_1.HttpException(`${ttl}秒内不得重复发送短信!`, common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const code = (0, utils_1.createRandomCode)();
|
||||
const messageInfo = { phone, code };
|
||||
await this.verificationService.sendPhoneCode(messageInfo);
|
||||
await this.redisCacheService.set({ key, val: code }, 1 * 60);
|
||||
return '验证码发送成功、请填写验证码完成注册!';
|
||||
}
|
||||
createTokenFromFingerprint(fingerprint) {
|
||||
const token = this.jwtService.sign({
|
||||
username: `游客${fingerprint}`,
|
||||
id: fingerprint,
|
||||
email: `${fingerprint}@nine.com`,
|
||||
role: 'visitor',
|
||||
openId: null,
|
||||
client: null,
|
||||
});
|
||||
return token;
|
||||
}
|
||||
};
|
||||
AuthService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(0, (0, typeorm_2.InjectRepository)(config_entity_1.ConfigEntity)),
|
||||
__metadata("design:paramtypes", [typeorm_1.Repository,
|
||||
user_service_1.UserService,
|
||||
jwt_1.JwtService,
|
||||
mailer_service_1.MailerService,
|
||||
verification_service_1.VerificationService,
|
||||
userBalance_service_1.UserBalanceService,
|
||||
redisCache_service_1.RedisCacheService,
|
||||
globalConfig_service_1.GlobalConfigService])
|
||||
], AuthService);
|
||||
exports.AuthService = AuthService;
|
||||
32
dist/modules/auth/dto/adminLogin.dto.js
vendored
Normal file
32
dist/modules/auth/dto/adminLogin.dto.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AdminLoginDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class AdminLoginDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'super', description: '邮箱' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户名不能为空!' }),
|
||||
(0, class_validator_1.MinLength)(2, { message: '用户名最短是两位数!' }),
|
||||
(0, class_validator_1.MaxLength)(30, { message: '用户名最长不得超过30位!' }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], AdminLoginDto.prototype, "username", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '999999', description: '密码' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户密码不能为空!' }),
|
||||
(0, class_validator_1.MinLength)(6, { message: '用户密码最低需要大于6位数!' }),
|
||||
(0, class_validator_1.MaxLength)(30, { message: '用户密码最长不能超过30位数!' }),
|
||||
__metadata("design:type", String)
|
||||
], AdminLoginDto.prototype, "password", void 0);
|
||||
exports.AdminLoginDto = AdminLoginDto;
|
||||
37
dist/modules/auth/dto/authLogin.dto.js
vendored
Normal file
37
dist/modules/auth/dto/authLogin.dto.js
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UserLoginDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class UserLoginDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'super', description: '邮箱' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户名不能为空!' }),
|
||||
(0, class_validator_1.MinLength)(2, { message: '用户名最短是两位数!' }),
|
||||
(0, class_validator_1.MaxLength)(30, { message: '用户名最长不得超过30位!' }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], UserLoginDto.prototype, "username", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '用户ID' }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], UserLoginDto.prototype, "uid", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '999999', description: '密码' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户密码不能为空!' }),
|
||||
(0, class_validator_1.MinLength)(6, { message: '用户密码最低需要大于6位数!' }),
|
||||
(0, class_validator_1.MaxLength)(30, { message: '用户密码最长不能超过30位数!' }),
|
||||
__metadata("design:type", String)
|
||||
], UserLoginDto.prototype, "password", void 0);
|
||||
exports.UserLoginDto = UserLoginDto;
|
||||
66
dist/modules/auth/dto/authRegister.dto.js
vendored
Normal file
66
dist/modules/auth/dto/authRegister.dto.js
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UserRegisterDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class UserRegisterDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'cooper', description: '用户名称' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户名不能为空!' }),
|
||||
(0, class_validator_1.MinLength)(2, { message: '用户名最低需要大于2位数!' }),
|
||||
(0, class_validator_1.MaxLength)(12, { message: '用户名不得超过12位!' }),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterDto.prototype, "username", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '123456', description: '用户密码' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户密码不能为空' }),
|
||||
(0, class_validator_1.MinLength)(6, { message: '用户密码最低需要大于6位数!' }),
|
||||
(0, class_validator_1.MaxLength)(30, { message: '用户密码最长不能超过30位数!' }),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterDto.prototype, "password", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'J_longyan@163.com', description: '用户邮箱' }),
|
||||
(0, class_validator_1.IsEmail)({}, { message: '请填写正确格式的邮箱!' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '邮箱不能为空!' }),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterDto.prototype, "email", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '5k3n', description: '图形验证码' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '验证码为空!' }),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterDto.prototype, "captchaCode", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '2313ko423ko', description: '图形验证码KEY' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '验证ID不能为空!' }),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterDto.prototype, "captchaId", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'FRJDLJHFNV', description: '用户填写的别人邀请码', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterDto.prototype, "invitedBy", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: 'https://public-1300678944.cos.ap-shanghai.myqcloud.com/blog/1682571295452image.png',
|
||||
description: '用户头像',
|
||||
required: false,
|
||||
}),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterDto.prototype, "avatar", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'default', description: '用户注册来源', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterDto.prototype, "client", void 0);
|
||||
exports.UserRegisterDto = UserRegisterDto;
|
||||
30
dist/modules/auth/dto/loginByPhone.dt.js
vendored
Normal file
30
dist/modules/auth/dto/loginByPhone.dt.js
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LoginByPhoneDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class LoginByPhoneDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '19999999', description: '手机号' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '手机号不能为空!' }),
|
||||
(0, class_validator_1.IsPhoneNumber)('CN', { message: '手机号格式不正确!' }),
|
||||
__metadata("design:type", String)
|
||||
], LoginByPhoneDto.prototype, "phone", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '999999', description: '密码' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户密码不能为空!' }),
|
||||
(0, class_validator_1.MinLength)(6, { message: '用户密码最低需要大于6位数!' }),
|
||||
(0, class_validator_1.MaxLength)(30, { message: '用户密码最长不能超过30位数!' }),
|
||||
__metadata("design:type", String)
|
||||
], LoginByPhoneDto.prototype, "password", void 0);
|
||||
exports.LoginByPhoneDto = LoginByPhoneDto;
|
||||
34
dist/modules/auth/dto/sendPhoneCode.dto.js
vendored
Normal file
34
dist/modules/auth/dto/sendPhoneCode.dto.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SendPhoneCodeDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class SendPhoneCodeDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '199999999', description: '手机号' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '手机号不能为空' }),
|
||||
(0, class_validator_1.MinLength)(11, { message: '手机号长度为11位' }),
|
||||
(0, class_validator_1.MaxLength)(11, { message: '手机号长度为11位!' }),
|
||||
__metadata("design:type", String)
|
||||
], SendPhoneCodeDto.prototype, "phone", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '2b4i1b4', description: '图形验证码KEY' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '验证码KEY不能为空' }),
|
||||
__metadata("design:type", String)
|
||||
], SendPhoneCodeDto.prototype, "captchaId", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '1g4d', description: '图形验证码' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '验证码不能为空' }),
|
||||
__metadata("design:type", String)
|
||||
], SendPhoneCodeDto.prototype, "captchaCode", void 0);
|
||||
exports.SendPhoneCodeDto = SendPhoneCodeDto;
|
||||
24
dist/modules/auth/dto/updatePassByOther.dto.js
vendored
Normal file
24
dist/modules/auth/dto/updatePassByOther.dto.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UpdatePassByOtherDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class UpdatePassByOtherDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '666666', description: '三方用户更新新密码' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户密码不能为空!' }),
|
||||
(0, class_validator_1.MinLength)(6, { message: '用户密码最低需要大于6位数!' }),
|
||||
(0, class_validator_1.MaxLength)(30, { message: '用户密码最长不能超过30位数!' }),
|
||||
__metadata("design:type", String)
|
||||
], UpdatePassByOtherDto.prototype, "password", void 0);
|
||||
exports.UpdatePassByOtherDto = UpdatePassByOtherDto;
|
||||
31
dist/modules/auth/dto/updatePassword.dto.js
vendored
Normal file
31
dist/modules/auth/dto/updatePassword.dto.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UpdatePasswordDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class UpdatePasswordDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '123456', description: '用户旧密码' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户密码不能为空!' }),
|
||||
(0, class_validator_1.MinLength)(6, { message: '用户密码最低需要大于6位数!' }),
|
||||
(0, class_validator_1.MaxLength)(30, { message: '用户密码最长不能超过30位数!' }),
|
||||
__metadata("design:type", String)
|
||||
], UpdatePasswordDto.prototype, "oldPassword", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '666666', description: '用户更新新密码' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户密码不能为空!' }),
|
||||
(0, class_validator_1.MinLength)(6, { message: '用户密码最低需要大于6位数!' }),
|
||||
(0, class_validator_1.MaxLength)(30, { message: '用户密码最长不能超过30位数!' }),
|
||||
__metadata("design:type", String)
|
||||
], UpdatePasswordDto.prototype, "password", void 0);
|
||||
exports.UpdatePasswordDto = UpdatePasswordDto;
|
||||
47
dist/modules/auth/dto/userRegisterByPhone.dto.js
vendored
Normal file
47
dist/modules/auth/dto/userRegisterByPhone.dto.js
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UserRegisterByPhoneDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class UserRegisterByPhoneDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'cooper', description: '用户名称' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户名不能为空!' }),
|
||||
(0, class_validator_1.MinLength)(2, { message: '用户名最低需要大于2位数!' }),
|
||||
(0, class_validator_1.MaxLength)(12, { message: '用户名不得超过12位!' }),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterByPhoneDto.prototype, "username", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '123456', description: '用户密码' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '用户密码不能为空' }),
|
||||
(0, class_validator_1.MinLength)(6, { message: '用户密码最低需要大于6位数!' }),
|
||||
(0, class_validator_1.MaxLength)(30, { message: '用户密码最长不能超过30位数!' }),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterByPhoneDto.prototype, "password", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '19999999999', description: '用户手机号码' }),
|
||||
(0, class_validator_1.IsPhoneNumber)('CN', { message: '手机号码格式不正确!' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '手机号码不能为空!' }),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterByPhoneDto.prototype, "phone", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '152546', description: '手机验证码' }),
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '手机验证码不能为空!' }),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterByPhoneDto.prototype, "phoneCode", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'SNINE', description: '用户邀请码', required: true }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterByPhoneDto.prototype, "invitedBy", void 0);
|
||||
exports.UserRegisterByPhoneDto = UserRegisterByPhoneDto;
|
||||
Reference in New Issue
Block a user