listSessions

This commit is contained in:
Max Peintner
2025-01-20 11:55:31 +01:00
parent f535b6da4c
commit 86679f14a0
2 changed files with 11 additions and 11 deletions

View File

@@ -12,13 +12,14 @@ import { getLocale, getTranslations } from "next-intl/server";
import { headers } from "next/headers"; import { headers } from "next/headers";
import Link from "next/link"; import Link from "next/link";
async function loadSessions() { async function loadSessions(host: string) {
const ids = await getAllSessionCookieIds(); const ids: (string | undefined)[] = await getAllSessionCookieIds();
if (ids && ids.length) { if (ids && ids.length) {
const response = await listSessions( const response = await listSessions({
ids.filter((id: string | undefined) => !!id), host,
); ids: ids.filter((id) => !!id) as string[],
});
return response?.sessions ?? []; return response?.sessions ?? [];
} else { } else {
console.info("No session cookie found."); console.info("No session cookie found.");
@@ -50,7 +51,7 @@ export default async function Page(props: {
} }
} }
let sessions = await loadSessions(); let sessions = await loadSessions(host);
const branding = await getBrandingSettings({ const branding = await getBrandingSettings({
host, host,

View File

@@ -362,13 +362,12 @@ export async function deleteSession({
return sessionService.deleteSession({ sessionId, sessionToken }, {}); return sessionService.deleteSession({ sessionId, sessionToken }, {});
} }
export async function listSessions({ type ListSessionsCommand = {
host,
ids,
}: {
host: string; host: string;
ids: string[]; ids: string[];
}) { };
export async function listSessions({ host, ids }: ListSessionsCommand) {
const sessionService: Client<typeof SessionService> = const sessionService: Client<typeof SessionService> =
await createServiceForHost(SessionService, host); await createServiceForHost(SessionService, host);