feat(auth): add active sessions management
Some checks failed
CI / test (push) Failing after 33s

- store refresh session metadata in redis (ip/user-agent/created_at)

- add auth APIs: list sessions, revoke one, revoke all

- add web privacy UI for active sessions
This commit is contained in:
2026-03-08 11:41:03 +03:00
parent da73b79ee7
commit e685a38be6
7 changed files with 309 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
import { http } from "./http";
import type { AuthUser, TokenPair } from "../chat/types";
import type { AuthSession, AuthUser, TokenPair } from "../chat/types";
export async function registerRequest(email: string, name: string, username: string, password: string): Promise<void> {
await http.post("/auth/register", { email, name, username, password });
@@ -19,3 +19,16 @@ export async function meRequest(): Promise<AuthUser> {
const { data } = await http.get<AuthUser>("/auth/me");
return data;
}
export async function listSessions(): Promise<AuthSession[]> {
const { data } = await http.get<AuthSession[]>("/auth/sessions");
return data;
}
export async function revokeSession(jti: string): Promise<void> {
await http.delete(`/auth/sessions/${jti}`);
}
export async function revokeAllSessions(): Promise<void> {
await http.delete("/auth/sessions");
}