Download functions/api/auth/logout.js from DOOOOOGF/afsdzfgdz: direct link, hf CLI and curl.
- Browser
- Download file 812 Bytes
-
https://huggingface.co/spaces/DOOOOOGF/afsdzfgdz/resolve/main/functions/api/auth/logout.js
- Command line
-
hf download hf://spaces/DOOOOOGF/afsdzfgdz/functions/api/auth/logout.js
-
curl -L -o logout.js https://huggingface.co/spaces/DOOOOOGF/afsdzfgdz/resolve/main/functions/api/auth/logout.js
812 Bytes
| import { destroySession } from "../../utils/auth/sessionManager.js"; | |
| export async function onRequestPost(context) { | |
| const { request, env } = context; | |
| // 从请求体中获取要登出的类型,默认清除所有 | |
| let authType = null; | |
| try { | |
| const body = await request.json(); | |
| authType = body.authType || null; | |
| } catch { | |
| // 没有请求体,清除所有 | |
| } | |
| const result = await destroySession(env, request, authType); | |
| // result 可能是单个字符串或数组 | |
| const headers = new Headers(); | |
| if (Array.isArray(result)) { | |
| result.forEach(cookie => headers.append('Set-Cookie', cookie)); | |
| } else { | |
| headers.set('Set-Cookie', result); | |
| } | |
| return new Response('Logged out', { | |
| status: 200, | |
| headers, | |
| }); | |
| } | |