feat(auth): Add type parameter to SendCode and update related API typings

This commit is contained in:
web@ppanel 2025-02-10 14:39:31 +07:00
parent e5455aa1dc
commit 4198871eef
14 changed files with 135 additions and 9 deletions

View File

@ -37,10 +37,11 @@ export default function SendCode({ type, params }: SendCodeProps) {
};
const getPhoneCode = async () => {
if (params.telephone && params.telephone_area_code) {
if (params.telephone && params.telephone_area_code && params.type) {
await sendSmsCode({
telephone: params.telephone,
telephone_area_code: params.telephone_area_code,
type: params.type,
});
setTargetDate(Date.now() + 60000);
}

View File

@ -1,5 +1,5 @@
// @ts-ignore
// API 更新时间:
// API 唯一标识:
import * as announcement from './announcement';

View File

@ -1401,6 +1401,7 @@ declare namespace API {
auth_type: string;
auth_identifier: string;
verified: boolean;
area_code?: string;
};
type UserBalanceLog = {

View File

@ -1,5 +1,5 @@
// @ts-ignore
// API 更新时间:
// API 唯一标识:
import * as auth from './auth';

View File

@ -348,6 +348,7 @@ declare namespace API {
};
type SendSmsCodeRequest = {
type: number;
telephone: string;
telephone_area_code: string;
};
@ -594,6 +595,7 @@ declare namespace API {
auth_type: string;
auth_identifier: string;
verified: boolean;
area_code?: string;
};
type UserBalanceLog = {

View File

@ -123,7 +123,13 @@ function MobileBindDialog({
<FormControl>
<div className='flex gap-2'>
<Input placeholder='Enter code...' type='text' {...field} />
<SendCode type='phone' params={form.getValues()} />
<SendCode
type='phone'
params={{
...form.getValues(),
type: 2,
}}
/>
</div>
</FormControl>

View File

@ -103,7 +103,15 @@ export default function LoginForm({
type={mode === 'code' ? 'text' : 'password'}
{...field}
/>
{mode === 'code' && <SendCode type='phone' params={form.getValues()} />}
{mode === 'code' && (
<SendCode
type='phone'
params={{
...form.getValues(),
type: 2,
}}
/>
)}
</div>
</FormControl>
<div className='!mt-0 text-right'>

View File

@ -153,7 +153,14 @@ export default function RegisterForm({
{...field}
value={field.value as string}
/>
<SendCode type='phone' params={form.getValues()} />
<SendCode
type='phone'
params={{
...form.getValues(),
type: 1,
}}
/>
</div>
</FormControl>
<FormMessage />

View File

@ -104,7 +104,13 @@ export default function ResetForm({
{...field}
value={field.value as string}
/>
<SendCode type='phone' params={form.getValues()} />
<SendCode
type='phone'
params={{
...form.getValues(),
type: 2,
}}
/>
</div>
</FormControl>
<FormMessage />

View File

@ -37,10 +37,11 @@ export default function SendCode({ type, params }: SendCodeProps) {
};
const getPhoneCode = async () => {
if (params.telephone && params.telephone_area_code) {
if (params.telephone && params.telephone_area_code && params.type) {
await sendSmsCode({
telephone: params.telephone,
telephone_area_code: params.telephone_area_code,
type: params.type,
});
setTargetDate(Date.now() + 60000);
}

View File

@ -1,5 +1,5 @@
// @ts-ignore
// API 更新时间:
// API 唯一标识:
import * as auth from './auth';

View File

@ -348,6 +348,7 @@ declare namespace API {
};
type SendSmsCodeRequest = {
type: number;
telephone: string;
telephone_area_code: string;
};
@ -594,6 +595,7 @@ declare namespace API {
auth_type: string;
auth_identifier: string;
verified: boolean;
area_code?: string;
};
type UserBalanceLog = {

View File

@ -70,6 +70,16 @@ declare namespace API {
enabled: boolean;
};
type BindEmailRequest = {
email: string;
};
type BindMobileRequest = {
area_code: string;
mobile: string;
code: string;
};
type BindOAuthCallbackRequest = {
method: string;
callback: Record<string, any>;
@ -89,6 +99,16 @@ declare namespace API {
expired_at: number;
};
type ChangebindEmailRequest = {
email: string;
};
type ChangebindMobileRequest = {
area_code: string;
mobile: string;
code: string;
};
type CheckoutOrderRequest = {
orderNo: string;
};
@ -783,6 +803,7 @@ declare namespace API {
auth_type: string;
auth_identifier: string;
verified: boolean;
area_code?: string;
};
type UserBalanceLog = {
@ -851,6 +872,11 @@ declare namespace API {
enable_reset_password_verify: boolean;
};
type VerifyEmailRequest = {
email: string;
code: string;
};
type Vless = {
port: number;
flow: string;

View File

@ -42,6 +42,30 @@ export async function queryUserBalanceLog(options?: { [key: string]: any }) {
);
}
/** Bind Email POST /v1/public/user/bind_email */
export async function bindEmail(body: API.BindEmailRequest, options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/public/user/bind_email', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** Bind Mobile POST /v1/public/user/bind_mobile */
export async function bindMobile(body: API.BindMobileRequest, options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/public/user/bind_mobile', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** Bind OAuth POST /v1/public/user/bind_oauth */
export async function bindOAuth(body: API.BindOAuthRequest, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.BindOAuthResponse }>('/v1/public/user/bind_oauth', {
@ -80,6 +104,36 @@ export async function bindTelegram(options?: { [key: string]: any }) {
);
}
/** Change Bind Email POST /v1/public/user/change_bind_email */
export async function changebindEmail(
body: API.ChangebindEmailRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: any }>('/v1/public/user/change_bind_email', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** Change Bind Mobile POST /v1/public/user/change_bind_mobile */
export async function changebindMobile(
body: API.ChangebindMobileRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: any }>('/v1/public/user/change_bind_mobile', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** Query User Commission Log GET /v1/public/user/commission_log */
export async function queryUserCommissionLog(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
@ -255,3 +309,15 @@ export async function preUnsubscribe(
},
);
}
/** Verify Email POST /v1/public/user/verify_email */
export async function verifyEmail(body: API.VerifyEmailRequest, options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/public/user/verify_email', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}