mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add function to fetch user info from api
This commit is contained in:
parent
aa9476680c
commit
a7f355531d
@ -10,7 +10,7 @@ JWT_SECRET=
|
||||
# used to verify who's making the jwt
|
||||
JWT_ISSUER=$PUBLIC_URL
|
||||
# keibi's server to retrieve the public jwt secret
|
||||
AUHT_SERVER=http://auth:4568
|
||||
AUTH_SERVER=http://auth:4568
|
||||
|
||||
IMAGES_PATH=./images
|
||||
|
||||
|
@ -69,3 +69,33 @@ export const auth = new Elysia({ name: "auth" })
|
||||
},
|
||||
})
|
||||
.as("plugin");
|
||||
|
||||
const User = t.Object({
|
||||
id: t.String({ format: "uuid" }),
|
||||
username: t.String(),
|
||||
email: t.String({ format: "email" }),
|
||||
createdDate: t.String({ format: "date-time" }),
|
||||
lastSeen: t.String({ format: "date-time" }),
|
||||
claims: t.Record(t.String(), t.Any()),
|
||||
oidc: t.Record(
|
||||
t.String(),
|
||||
t.Object({
|
||||
id: t.String({ format: "uuid" }),
|
||||
username: t.String(),
|
||||
profileUrl: t.Nullable(t.String({ format: "url" })),
|
||||
}),
|
||||
),
|
||||
});
|
||||
const UserC = TypeCompiler.Compile(User);
|
||||
|
||||
export async function getUserInfo(
|
||||
id: string,
|
||||
headers: { authorization: string },
|
||||
) {
|
||||
const resp = await fetch(
|
||||
new URL(`/auth/users/${id}`, process.env.AUTH_SERVER ?? "http://auth:4568"),
|
||||
{ headers },
|
||||
);
|
||||
|
||||
return UserC.Decode(await resp.json());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user