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,4 +1,4 @@
|
|||
import { readAccounts } from "~/server/database";
|
||||
import { readUsers } from "~/server/database";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { name } = await readBody(event);
|
||||
|
@ -7,12 +7,12 @@ export default defineEventHandler(async (event) => {
|
|||
return new Response(undefined, { status: 400 })
|
||||
}
|
||||
|
||||
const accounts = await readAccounts();
|
||||
const accounts = await readUsers();
|
||||
const account = accounts.find(a => a.name === name);
|
||||
|
||||
if (!account) {
|
||||
return new Response(undefined, { status: 403 })
|
||||
}
|
||||
|
||||
await setServerSession(event, account.id);
|
||||
await setServerSession(event, account);
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue