"use server"; import { createAuthorization } from "@/lib/dto/authorization"; import { getAuthorizeUrl } from "@/lib/oauth/authorize-url"; export async function handleAuthorizeAction( oauth: string, userId: string, clientId: string, scope: string, ) { const oauthParams = new URLSearchParams(atob(oauth)); const redirectUrl = getAuthorizeUrl(oauthParams); // 保存授权 await createAuthorization({ userId, clientId, scope, enabled: true, // 新授权默认启用 lastUsedAt: new Date(), // 首次授权时间作为最后使用时间 }); return redirectUrl; }