build-container / build (push) Successful in 4m30s
- Admin can make a screen a family device; it opens on a family board - Name tiles with KID labels; kids tap, others enter a PIN (lockout after 5 wrong tries) - Name label with Switch user, auto-return to the board after 5 idle minutes - Short 30-minute sessions on family devices - Settings section for PIN and turning a device on or off - Test, README and roadmap updated Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
12 lines
1.2 KiB
JavaScript
12 lines
1.2 KiB
JavaScript
// Family devices: shared screens (a kitchen tablet, the family computer) that open on the family board instead of a sign-in. An admin makes a device one
|
|
// while signed in on it; the device keeps a signed cookie, and this list is what lets an admin switch one off again. Kept in DATA_DIR/devices.json.
|
|
const fs = require('fs'), path = require('path'), crypto = require('crypto');
|
|
const atomicWrite = require('./atomic');
|
|
const FILE = () => path.join(process.env.DATA_DIR || path.join(__dirname, 'data'), 'devices.json');
|
|
const load = () => { try { const j = JSON.parse(fs.readFileSync(FILE(), 'utf8')); return Array.isArray(j.devices) ? j.devices : []; } catch { return []; } };
|
|
const save = l => { fs.mkdirSync(path.dirname(FILE()), { recursive: true }); atomicWrite(FILE(), JSON.stringify({ devices: l }), { mode: 0o600 }); };
|
|
const has = id => load().some(d => d.id === id);
|
|
const add = (name, by) => { const d = { id: crypto.randomBytes(9).toString('base64url'), name: String(name || 'Family device').slice(0, 40), by, created: Date.now() }; save([...load(), d]); return d; };
|
|
const remove = id => save(load().filter(d => d.id !== id));
|
|
module.exports = { load, has, add, remove };
|