Switch to internally managed roles, adapt frontend
This commit is contained in:
@@ -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 ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user