v2: fixed oauth errors, oauth clients native control added

This commit is contained in:
Ivan Rezchikov
2026-09-15 16:21:53 +03:00
parent 83e1849d73
commit 8b0a3d143b
51 changed files with 1392 additions and 3216 deletions
+8 -8
View File
@@ -3,9 +3,9 @@
import { Consent } from "@/types"
import { cookies } from "next/headers"
export async function fetchConsents() {
const store = await cookies()
const accessToken = store.get("access_token")?.value
export async function fetchConsents(): Promise<Consent[] | []> {
const store = await cookies();
const accessToken = store.get("access_token")?.value;
const response = await fetch(
`${process.env.KOTOSOFT_ID_API_URL}/api/v1/me/consents`,
@@ -14,16 +14,16 @@ export async function fetchConsents() {
Authorization: `Bearer ${accessToken}`,
},
}
)
);
if (!response.ok) return []
if (!response.ok) return [];
const consents = await response.json() as Consent[]
const consents = await response.json() as Consent[];
consents?.forEach((consent: Consent) => {
consent.isRevokable = consent.client_id !== process.env.CLIENT_ID
})
});
return consents
return consents;
}
export async function revokeConsent(clientId: string) {