mirror of
https://github.com/vastxie/99AI.git
synced 2025-11-13 04:03:45 +08:00
v3.7.0
This commit is contained in:
11
dist/modules/auth/auth.controller.js
vendored
11
dist/modules/auth/auth.controller.js
vendored
@@ -43,9 +43,6 @@ let AuthController = class AuthController {
|
||||
async getInfo(req) {
|
||||
return this.authService.getInfo(req);
|
||||
}
|
||||
async captcha(parmas) {
|
||||
return this.authService.captcha(parmas);
|
||||
}
|
||||
async sendCode(parmas) {
|
||||
return this.authService.sendCode(parmas);
|
||||
}
|
||||
@@ -109,14 +106,6 @@ __decorate([
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "getInfo", 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)('sendCode'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '发送验证码' }),
|
||||
|
||||
33
dist/modules/auth/auth.service.js
vendored
33
dist/modules/auth/auth.service.js
vendored
@@ -21,7 +21,6 @@ const jwt_1 = require("@nestjs/jwt");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const bcrypt = require("bcryptjs");
|
||||
const os = require("os");
|
||||
const svgCaptcha = require("svg-captcha");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const config_entity_1 = require("../globalConfig/config.entity");
|
||||
const mailer_service_1 = require("../mailer/mailer.service");
|
||||
@@ -44,7 +43,6 @@ let AuthService = class AuthService {
|
||||
this.getIp();
|
||||
}
|
||||
async register(body, req) {
|
||||
await this.verificationService.verifyCaptcha(body);
|
||||
const { password, contact, code, invitedBy } = body;
|
||||
let email = '', phone = '';
|
||||
const isEmail = /\S+@\S+\.\S+/.test(contact);
|
||||
@@ -99,11 +97,11 @@ let AuthService = class AuthService {
|
||||
throw new common_1.HttpException('请输入验证码', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (!redisCode) {
|
||||
common_1.Logger.log(`验证码过期: ${contact}`);
|
||||
common_1.Logger.log(`验证码过期: ${contact}`, 'authService');
|
||||
throw new common_1.HttpException('验证码已过期,请重新发送!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (code !== redisCode) {
|
||||
common_1.Logger.log(`验证码错误: ${contact} 输入的验证码: ${code}, 期望的验证码: ${redisCode}`);
|
||||
common_1.Logger.log(`验证码错误: ${contact} 输入的验证码: ${code}, 期望的验证码: ${redisCode}`, 'authService');
|
||||
throw new common_1.HttpException('验证码填写错误,请重新输入!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
@@ -197,11 +195,11 @@ let AuthService = class AuthService {
|
||||
const key = `${nameSpace}:CODE:${contact}`;
|
||||
const redisCode = await this.redisCacheService.get({ key });
|
||||
if (!redisCode) {
|
||||
common_1.Logger.log(`验证码过期: ${contact}`);
|
||||
common_1.Logger.log(`验证码过期: ${contact}`, 'authService');
|
||||
throw new common_1.HttpException('验证码已过期,请重新发送!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (code !== redisCode) {
|
||||
common_1.Logger.log(`验证码错误: ${contact} 输入的验证码: ${code}, 期望的验证码: ${redisCode}`);
|
||||
common_1.Logger.log(`验证码错误: ${contact} 输入的验证码: ${code}, 期望的验证码: ${redisCode}`, 'authService');
|
||||
throw new common_1.HttpException('验证码填写错误,请重新输入!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
let u;
|
||||
@@ -292,28 +290,6 @@ let AuthService = class AuthService {
|
||||
});
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
async captcha(parmas) {
|
||||
const nameSpace = await this.globalConfigService.getNamespace();
|
||||
const { color = '#fff' } = parmas;
|
||||
const captcha = svgCaptcha.create({
|
||||
size: 4,
|
||||
ignoreChars: '0o1i',
|
||||
noise: 4,
|
||||
color: true,
|
||||
background: color,
|
||||
height: 35,
|
||||
width: 120,
|
||||
charPreset: 'abcdefghijklmnopqrstuvwxyz',
|
||||
});
|
||||
const text = captcha.text;
|
||||
const randomId = Math.random().toString(36).substr(2, 9);
|
||||
const key = `${nameSpace}:CAPTCHA:${randomId}`;
|
||||
await this.redisCacheService.set({ key, val: text }, 5 * 60);
|
||||
return {
|
||||
svgCode: captcha.data,
|
||||
code: randomId,
|
||||
};
|
||||
}
|
||||
async sendCode(body) {
|
||||
const { contact, isLogin } = body;
|
||||
let email = '', phone = '';
|
||||
@@ -324,7 +300,6 @@ let AuthService = class AuthService {
|
||||
throw new common_1.HttpException('请提供有效的邮箱地址或手机号码。', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (!isLogin) {
|
||||
await this.verificationService.verifyCaptcha(body);
|
||||
if (isEmail) {
|
||||
email = contact;
|
||||
const isAvailable = await this.userService.verifyUserRegister({
|
||||
|
||||
10
dist/modules/auth/dto/authRegister.dto.js
vendored
10
dist/modules/auth/dto/authRegister.dto.js
vendored
@@ -29,16 +29,6 @@ __decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'ai@aiweb.com', description: '用户邮箱' }),
|
||||
__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',
|
||||
|
||||
@@ -10,8 +10,8 @@ var __metadata = (this && this.__metadata) || function (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");
|
||||
const class_validator_1 = require("class-validator");
|
||||
class UserRegisterByPhoneDto {
|
||||
}
|
||||
__decorate([
|
||||
|
||||
Reference in New Issue
Block a user