fix(auth): 修复注册接口中的邀请码参数处理

- 将 RegisterRequestDto 和 RegisterPayload 中的 invite_code 字段改为可选字段
- 修改 registerWithPassword 函数中的请求体构建逻辑,仅在有值时包含邀请码参数
- 移除邀请码验证 schema 中的必填校验规则
- 更新云开发预览配置文件中的端口和进程 ID 信息
This commit is contained in:
JiaJun
2026-07-22 09:43:04 +08:00
parent 1b7557e2cc
commit cf9300eefc
4 changed files with 17 additions and 16 deletions

View File

@@ -1,12 +1,12 @@
{ {
"pid": 98343, "pid": 24641,
"port": 17174, "port": 17175,
"host": "0.0.0.0", "host": "0.0.0.0",
"base": "/", "base": "/",
"framework": "vite-react", "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 /", "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:17174/", "internalUrl": "http://127.0.0.1:17175/",
"logPath": "/Users/jiaunun/Desktop/36-character-flower/.cloudbase-sites/logs/preview-1784093877629.log", "logPath": "/Users/jiaunun/Desktop/36-character-flower/.cloudbase-sites/logs/preview-1784622161040.log",
"cwd": "/Users/jiaunun/Desktop/36-character-flower", "cwd": "/Users/jiaunun/Desktop/36-character-flower",
"startedAt": "2026-07-15T05:37:58.655Z" "startedAt": "2026-07-21T08:22:42.070Z"
} }

View File

@@ -145,16 +145,18 @@ export async function logoutWithPassword(
export async function registerWithPassword( export async function registerWithPassword(
payload: RegisterPayload, payload: RegisterPayload,
): Promise<AuthSessionInput> { ): Promise<AuthSessionInput> {
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<AuthSessionDto, RegisterRequestDto>( const response = await api.post<AuthSessionDto, RegisterRequestDto>(
AUTH_ENDPOINTS.register, AUTH_ENDPOINTS.register,
{ {
json: { json: registerRequest,
captcha: payload.captcha,
device_id: getAuthDeviceId(),
invite_code: payload.inviteCode,
password: payload.password,
username: payload.mobile,
},
}, },
) )

View File

@@ -35,7 +35,6 @@ export const registerFormSchema = z
inviteCode: z inviteCode: z
.string() .string()
.trim() .trim()
.min(1, 'auth.validation.inviteCode.required')
.max(INVITE_CODE_MAX_LENGTH, 'auth.validation.inviteCode.max'), .max(INVITE_CODE_MAX_LENGTH, 'auth.validation.inviteCode.max'),
password: passwordSchema, password: passwordSchema,
mobile: usernameSchema, mobile: usernameSchema,

View File

@@ -120,7 +120,7 @@ export interface LogoutRequestDto {
export interface RegisterRequestDto { export interface RegisterRequestDto {
captcha: string captcha: string
device_id?: string device_id?: string
invite_code: string invite_code?: string
password: string password: string
username: string username: string
} }
@@ -148,7 +148,7 @@ export type LogoutPayload = LoginPayload
export interface RegisterPayload { export interface RegisterPayload {
captcha: string captcha: string
inviteCode: string inviteCode?: string
mobile: string mobile: string
password: string password: string
} }