Switch to internally managed roles, adapt frontend

This commit is contained in:
2025-10-07 02:04:35 +02:00
parent dc0ec5c635
commit 90729736ca
11 changed files with 248 additions and 351 deletions

View File

@@ -9,6 +9,11 @@ import * as Database from "./services/Database";
const READ_ACCESS = HashSet.make(Role.Editor, Role.Viewer);
const WRITE_ACCESS = HashSet.make(Role.Editor);
const requireAuthenticated = pipe(
Authentication.Authentication,
Effect.flatMap(({ me }) => me),
);
const requireReadAccess = pipe(
Authentication.Authentication,
Effect.flatMap(({ me }) => me),
@@ -39,10 +44,14 @@ export const handle = implement(api, {
Authentication.Authentication,
Effect.flatMap(({ logout }) => logout),
),
getUser: (userId) => pipe(
Authentication.Authentication,
Effect.flatMap(({ getUser }) => getUser(userId)),
),
getUser: (userId) => Effect.gen(function* () {
yield* requireAuthenticated;
const { getUser } = yield* Authentication.Authentication;
const user = yield* getUser(userId);
return user;
}),
// --- Piece CRUD ---