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,14 +1,9 @@
|
|||
import { readAccounts } from "~/server/database";
|
||||
import { cancelSessionStreams } from "~/server/streams";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const session = await getServerSession(event);
|
||||
if (session) {
|
||||
const accounts = await readAccounts();
|
||||
const account = accounts.find(
|
||||
account => account.id === session.accountId
|
||||
);
|
||||
if (account && account.type === "anonymous") {
|
||||
if (session.account.type === "anonymous") {
|
||||
throw createError({
|
||||
status: 409,
|
||||
message: "Cannot log out of an anonymous account",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue