diff --git a/src/server/modules/auth/auth.service.ts b/src/server/modules/auth/auth.service.ts index 4a3a1bc..0e4bf1e 100644 --- a/src/server/modules/auth/auth.service.ts +++ b/src/server/modules/auth/auth.service.ts @@ -4,8 +4,6 @@ import { UserEntity as User } from '../users/user.entity'; const JWT_SECRET = 'your-secret-key'; // 生产环境应使用环境变量 const JWT_EXPIRES_IN = '7d'; // 7天有效期 -const CODE_EXPIRATION = 5 * 60; // 5分钟有效期(秒) -const CODE_KEY_PREFIX = 'auth:code:'; export class AuthService { private userService: UserService; @@ -52,35 +50,6 @@ export class AuthService { } } - generateFixedCode(phone: string): string { - // 基于手机号生成固定6位验证码 - const phoneHash = Array.from(phone).reduce((hash, char) => - ((hash << 5) - hash + char.charCodeAt(0)) | 0, 0); - const code = Math.abs(phoneHash % 900000 + 100000).toString(); - // 位数不足时补0 - return code.padEnd(6, '0'); - } - - async generateRandCode(phone: string): Promise { - try { - const code = Math.floor(100000 + Math.random() * 900000).toString(); - const key = `${CODE_KEY_PREFIX}${phone}`; - - return code; - } catch (error) { - console.error('Redis set code error:', error); - throw new Error('验证码生成失败'); - } - } - - async verifyCode(phone: string, code: string): Promise { - if (this.generateFixedCode(phone) === code) { - return true; - } - - return true; - } - async logout(token: string): Promise { try { // 验证token有效性