feat: add admin social login bindings

This commit is contained in:
237899745
2026-05-27 21:24:48 +08:00
parent 5dbe666420
commit 89cb98233f
39 changed files with 904 additions and 123 deletions

View File

@@ -276,6 +276,26 @@ def ensure_schema(conn) -> None:
"""
)
# 管理员聚合登录绑定表
cursor.execute(
"""
CREATE TABLE IF NOT EXISTS admin_social_login_bindings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
admin_id INTEGER NOT NULL,
provider TEXT NOT NULL,
social_uid TEXT NOT NULL,
nickname TEXT DEFAULT '',
avatar_url TEXT DEFAULT '',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_login_at TIMESTAMP,
UNIQUE (provider, social_uid),
UNIQUE (admin_id, provider),
FOREIGN KEY (admin_id) REFERENCES admins (id) ON DELETE CASCADE
)
"""
)
# 聚合登录短期待绑定凭证表
cursor.execute(
"""
@@ -432,6 +452,10 @@ def ensure_schema(conn) -> None:
cursor.execute("CREATE INDEX IF NOT EXISTS idx_passkeys_owner_last_used ON passkeys(owner_type, owner_id, last_used_at)")
cursor.execute("CREATE INDEX IF NOT EXISTS idx_social_login_bindings_user ON social_login_bindings(user_id)")
cursor.execute("CREATE INDEX IF NOT EXISTS idx_social_login_bindings_provider_uid ON social_login_bindings(provider, social_uid)")
cursor.execute("CREATE INDEX IF NOT EXISTS idx_admin_social_login_bindings_admin ON admin_social_login_bindings(admin_id)")
cursor.execute(
"CREATE INDEX IF NOT EXISTS idx_admin_social_login_bindings_provider_uid ON admin_social_login_bindings(provider, social_uid)"
)
cursor.execute("CREATE INDEX IF NOT EXISTS idx_social_pending_binds_token ON social_pending_binds(token)")
cursor.execute("CREATE INDEX IF NOT EXISTS idx_social_pending_binds_provider_uid ON social_pending_binds(provider, social_uid)")
cursor.execute("CREATE INDEX IF NOT EXISTS idx_social_pending_binds_expires ON social_pending_binds(expires_at)")