v2: fixed oauth errors, oauth clients native control added
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user