Spaces:
Runtime error
Runtime error
File size: 602 Bytes
03138b9 8feb641 03138b9 6407b30 03138b9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
export const isAdmin = async (headers: Headers) => {
return new Promise(async (resolve, reject) => {
const Authorization = headers.get('Authorization') ?? undefined
// @ts-ignore
const HF_ADMIN = process?.env?.HF_ADMIN?.split(',') ?? []
const userRequest = await fetch("https://huggingface.co./oauth/userinfo", {
method: "GET",
headers: {
Authorization: `${Authorization}`,
},
})
const user = await userRequest.clone().json().catch(() => ({}));
const is_admin = user?.sub ? HF_ADMIN.includes(user?.sub) : false
resolve(is_admin)
})
} |