From cf9300eefcb6508d6959be450c90e071b038c19c Mon Sep 17 00:00:00 2001 From: JiaJun <2394389886@qq.com> Date: Wed, 22 Jul 2026 09:43:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(auth):=20=E4=BF=AE=E5=A4=8D=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E6=8E=A5=E5=8F=A3=E4=B8=AD=E7=9A=84=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E7=A0=81=E5=8F=82=E6=95=B0=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 RegisterRequestDto 和 RegisterPayload 中的 invite_code 字段改为可选字段 - 修改 registerWithPassword 函数中的请求体构建逻辑,仅在有值时包含邀请码参数 - 移除邀请码验证 schema 中的必填校验规则 - 更新云开发预览配置文件中的端口和进程 ID 信息 --- .cloudbase-sites/preview.json | 12 ++++++------ src/api/auth-api.ts | 16 +++++++++------- src/schema/auth-schema.ts | 1 - src/type/auth.type.ts | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.cloudbase-sites/preview.json b/.cloudbase-sites/preview.json index 9535b25..0d41aa0 100644 --- a/.cloudbase-sites/preview.json +++ b/.cloudbase-sites/preview.json @@ -1,12 +1,12 @@ { - "pid": 98343, - "port": 17174, + "pid": 24641, + "port": 17175, "host": "0.0.0.0", "base": "/", "framework": "vite-react", - "command": "/Users/jiaunun/.nvm/versions/node/v24.15.0/bin/node /Users/jiaunun/Desktop/36-character-flower/node_modules/vite/bin/vite.js --host 0.0.0.0 --port 17174 --strictPort --base /", - "internalUrl": "http://127.0.0.1:17174/", - "logPath": "/Users/jiaunun/Desktop/36-character-flower/.cloudbase-sites/logs/preview-1784093877629.log", + "command": "/Users/jiaunun/.nvm/versions/node/v24.15.0/bin/node /Users/jiaunun/Desktop/36-character-flower/node_modules/vite/bin/vite.js --host 0.0.0.0 --port 17175 --strictPort --base /", + "internalUrl": "http://127.0.0.1:17175/", + "logPath": "/Users/jiaunun/Desktop/36-character-flower/.cloudbase-sites/logs/preview-1784622161040.log", "cwd": "/Users/jiaunun/Desktop/36-character-flower", - "startedAt": "2026-07-15T05:37:58.655Z" + "startedAt": "2026-07-21T08:22:42.070Z" } diff --git a/src/api/auth-api.ts b/src/api/auth-api.ts index edc0d42..1ec9473 100644 --- a/src/api/auth-api.ts +++ b/src/api/auth-api.ts @@ -145,16 +145,18 @@ export async function logoutWithPassword( export async function registerWithPassword( payload: RegisterPayload, ): Promise { + const inviteCode = payload.inviteCode?.trim() ?? '' + const registerRequest: RegisterRequestDto = { + captcha: payload.captcha, + device_id: getAuthDeviceId(), + password: payload.password, + username: payload.mobile, + ...(inviteCode ? { invite_code: inviteCode } : {}), + } const response = await api.post( AUTH_ENDPOINTS.register, { - json: { - captcha: payload.captcha, - device_id: getAuthDeviceId(), - invite_code: payload.inviteCode, - password: payload.password, - username: payload.mobile, - }, + json: registerRequest, }, ) diff --git a/src/schema/auth-schema.ts b/src/schema/auth-schema.ts index a19fcf0..5f985da 100644 --- a/src/schema/auth-schema.ts +++ b/src/schema/auth-schema.ts @@ -35,7 +35,6 @@ export const registerFormSchema = z inviteCode: z .string() .trim() - .min(1, 'auth.validation.inviteCode.required') .max(INVITE_CODE_MAX_LENGTH, 'auth.validation.inviteCode.max'), password: passwordSchema, mobile: usernameSchema, diff --git a/src/type/auth.type.ts b/src/type/auth.type.ts index 895d0ab..1be2be3 100644 --- a/src/type/auth.type.ts +++ b/src/type/auth.type.ts @@ -120,7 +120,7 @@ export interface LogoutRequestDto { export interface RegisterRequestDto { captcha: string device_id?: string - invite_code: string + invite_code?: string password: string username: string } @@ -148,7 +148,7 @@ export type LogoutPayload = LoginPayload export interface RegisterPayload { captcha: string - inviteCode: string + inviteCode?: string mobile: string password: string }