Implement registration whitelist flow

This commit is contained in:
Tim
2025-07-14 22:03:45 +08:00
parent c9c96edcb0
commit e4e83197d2
28 changed files with 353 additions and 47 deletions

View File

@@ -1,7 +1,7 @@
import { API_BASE_URL, GOOGLE_CLIENT_ID, toast } from '../main'
import { setToken, loadCurrentUser } from './auth'
export function googleSignIn(redirect) {
export function googleSignIn(redirect, reason) {
if (!window.google || !GOOGLE_CLIENT_ID) {
toast.error('Google 登录不可用')
return
@@ -13,7 +13,7 @@ export function googleSignIn(redirect) {
const res = await fetch(`${API_BASE_URL}/api/auth/google`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ idToken: credential })
body: JSON.stringify({ idToken: credential, reason })
})
const data = await res.json()
if (res.ok && data.token) {