完善权限获取机制

This commit is contained in:
2026-03-31 11:59:00 +08:00
parent 12b60e74df
commit 61b766d939
7 changed files with 56 additions and 53 deletions

View File

@@ -1,7 +1,7 @@
"use server"
import { cookies } from "next/headers"
import type { ApiResponse } from "@/lib/api"
import type { User } from "@/models/user"
import type { Admin } from "@/models/admin"
import { callByDevice, callByUser } from "./base"
export type TokenResp = {
@@ -79,7 +79,7 @@ export async function logout() {
}
export async function getProfile() {
return await callByUser<User>("/api/auth/introspect")
return await callByUser<Admin & { scopes: string[] }>("/api/auth/introspect")
}
export async function refreshAuth() {
@@ -128,5 +128,6 @@ export async function refreshAuth() {
return {
access_token: nextAccessToken,
refresh_token: nextRefreshToken,
scopes: data.scope?.split(" ") || [],
}
}