Spaces:
Runtime error
Runtime error
Download src/lib/server/api/authPlugin.ts from evijit/pluralchat: direct link, hf CLI and curl.
- Browser
- Download file 491 Bytes
-
https://huggingface.co/spaces/evijit/pluralchat/resolve/refs%2Fpr%2F1/src/lib/server/api/authPlugin.ts
- Command line
-
hf download hf://spaces/evijit/pluralchat@refs/pr/1/src/lib/server/api/authPlugin.ts
-
curl -L -o authPlugin.ts https://huggingface.co/spaces/evijit/pluralchat/resolve/refs%2Fpr%2F1/src/lib/server/api/authPlugin.ts
491 Bytes
| import Elysia from "elysia"; | |
| import { authenticateRequest } from "../auth"; | |
| export const authPlugin = new Elysia({ name: "auth" }).derive( | |
| { as: "scoped" }, | |
| async ({ | |
| headers, | |
| cookie, | |
| }): Promise<{ | |
| locals: App.Locals; | |
| }> => { | |
| const auth = await authenticateRequest( | |
| { type: "elysia", value: headers }, | |
| { type: "elysia", value: cookie }, | |
| true | |
| ); | |
| return { | |
| locals: { | |
| user: auth?.user, | |
| sessionId: auth?.sessionId, | |
| isAdmin: auth?.isAdmin, | |
| }, | |
| }; | |
| } | |
| ); | |