mirror of
https://github.com/bitbaum/causius.git
synced 2026-12-04 05:48:05 +01:00
- Helpers list themselves (AI service, legal assistant, licensed lawyer) under a name or pseudonym; the same account keeps matters of its own. Directory search and filters through searchkit and listkit, with the typo suite. - A lawyer's admission is submitted privately (evidence sealed per credential), checked by a staff reviewer, and published as an SD-JWT signed with Ed25519: the place in clear, the legal name only as a salted digest. Key at /.well-known/jwks.json; anyone can check at /verify. A lawyer is listed only where verified. - An owner asks a helper about a matter, with or without their personal details; the request is previewed exactly as it will be read. Accepted, the helper becomes a participant; anonymisation is applied in the store, so no route can forget it. A lawyer hands over the checked name with proof. Ending it removes access in the same transaction. - Reviewers are staff/admin accounts, granted by the Grant role workflow. - Who may do what is lib/professions.ts, the one domain file, so Diplodoctor reuses the engine by changing it. - Fixes: the account menu label template; one site URL instead of three, with a dev-only origin so local sign-in works. Claude-Session: https://claude.ai/code/session_018Lem7GyhyyjKhmwjG8G7Ud Co-authored-by: Claude <noreply@anthropic.com>
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
// Give an account a role (accountkit's ROLES). The only way a role changes:
|
|
// nobody chooses their own — sign-up ignores it — and there is no web form.
|
|
// "staff" or "admin" may review helpers' credentials at /review.
|
|
//
|
|
// DATABASE_URL=… pnpm run role:grant <email-or-user-id> <role>
|
|
//
|
|
// Run it where the database is: on the box, the "Grant role" workflow does.
|
|
// It prints which account changed, never anything else about it.
|
|
import pg from "pg";
|
|
|
|
const ROLES = ["customer", "helper", "professional", "staff", "admin"];
|
|
const [who, role] = process.argv.slice(2);
|
|
|
|
if (!who || !ROLES.includes(role ?? "")) {
|
|
console.error(`usage: role:grant <email-or-user-id> <${ROLES.join("|")}>`);
|
|
process.exit(2);
|
|
}
|
|
if (!process.env.DATABASE_URL) {
|
|
console.error("DATABASE_URL is not set");
|
|
process.exit(2);
|
|
}
|
|
|
|
const client = new pg.Client({ connectionString: process.env.DATABASE_URL });
|
|
await client.connect();
|
|
try {
|
|
const { rows } = await client.query(
|
|
"update users set role = $2, updated_at = now() where id = $1 or lower(email) = lower($1) returning id",
|
|
[who, role],
|
|
);
|
|
if (rows.length !== 1) {
|
|
console.error(rows.length === 0 ? "no such account" : "more than one account matched — use the id");
|
|
process.exit(1);
|
|
}
|
|
console.warn(`account ${rows[0].id} is now ${role}`);
|
|
} finally {
|
|
await client.end();
|
|
}
|