fix(auth): 修复注册接口中的邀请码参数处理
- 将 RegisterRequestDto 和 RegisterPayload 中的 invite_code 字段改为可选字段 - 修改 registerWithPassword 函数中的请求体构建逻辑,仅在有值时包含邀请码参数 - 移除邀请码验证 schema 中的必填校验规则 - 更新云开发预览配置文件中的端口和进程 ID 信息
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
@@ -145,16 +145,18 @@ export async function logoutWithPassword(
|
||||
export async function registerWithPassword(
|
||||
payload: RegisterPayload,
|
||||
): 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>(
|
||||
AUTH_ENDPOINTS.register,
|
||||
{
|
||||
json: {
|
||||
captcha: payload.captcha,
|
||||
device_id: getAuthDeviceId(),
|
||||
invite_code: payload.inviteCode,
|
||||
password: payload.password,
|
||||
username: payload.mobile,
|
||||
},
|
||||
json: registerRequest,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user