Add beta mode

This commit is contained in:
icy
2025-11-02 02:31:19 +08:00
parent 2cc91d1701
commit 5c8a20e8d4
6 changed files with 464 additions and 6 deletions

View File

@@ -10,7 +10,7 @@ interface AuthContextType {
user: User | null;
token: string | null;
login: (email: string, password: string) => Promise<{ success: boolean; message?: string; userID?: string; requiresOTP?: boolean }>;
register: (email: string, password: string) => Promise<{ success: boolean; message?: string; userID?: string; otpSecret?: string; qrCodeURL?: string }>;
register: (email: string, password: string, betaCode?: string) => Promise<{ success: boolean; message?: string; userID?: string; otpSecret?: string; qrCodeURL?: string }>;
verifyOTP: (userID: string, otpCode: string) => Promise<{ success: boolean; message?: string }>;
completeRegistration: (userID: string, otpCode: string) => Promise<{ success: boolean; message?: string }>;
logout: () => void;
@@ -89,14 +89,19 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
return { success: false, message: '未知错误' };
};
const register = async (email: string, password: string) => {
const register = async (email: string, password: string, betaCode?: string) => {
try {
const requestBody: { email: string; password: string; beta_code?: string } = { email, password };
if (betaCode) {
requestBody.beta_code = betaCode;
}
const response = await fetch('/api/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email, password }),
body: JSON.stringify(requestBody),
});
const data = await response.json();