Refactor user storage and update
Rename accounts to users to be consistent with the new naming scheme where account only referes to the logged in user of the session and implement live updates of users via a user store which listens for updates from the event stream.
This commit is contained in:
parent
6336ccdb96
commit
3be7f8be05
24 changed files with 331 additions and 182 deletions
|
@ -1,5 +1,5 @@
|
|||
import type { H3Event } from "h3";
|
||||
import { nextSessionId, readSessions, readSubscriptions, type ServerSession, writeSessions, writeSubscriptions } from "~/server/database";
|
||||
import { nextSessionId, readSessions, readSubscriptions, type ServerSession, type ServerUser, writeSessions, writeSubscriptions } from "~/server/database";
|
||||
|
||||
const oneYearSeconds = 365 * 24 * 60 * 60;
|
||||
|
||||
|
@ -34,12 +34,12 @@ export async function clearServerSession(event: H3Event) {
|
|||
deleteCookie(event, "session");
|
||||
}
|
||||
|
||||
export async function setServerSession(event: H3Event, accountId: number) {
|
||||
export async function setServerSession(event: H3Event, account: ServerUser) {
|
||||
const sessions = await readSessions();
|
||||
await clearServerSessionInternal(event, sessions);
|
||||
|
||||
const newSession: ServerSession = {
|
||||
accountId,
|
||||
account,
|
||||
id: await nextSessionId(),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue