mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-18 05:51:55 +08:00
26 lines
604 B
TypeScript
26 lines
604 B
TypeScript
"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;
|
|
}
|