Gestion des utilisateurs

This commit is contained in:
2026-06-15 07:32:36 +02:00
parent 414c8dbb74
commit f3c5387a92
11 changed files with 1163 additions and 128 deletions
+22
View File
@@ -1800,4 +1800,26 @@ db.exec('CREATE INDEX IF NOT EXISTS idx_2fa_dev_uid ON two_fa_trusted_devices(
console.log('[DB] Migrations 2FA OK');
// ── Table invitations ────────────────────────────────────────────────────────
{
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='invitations'").get();
if (!tables) {
db.exec(`
CREATE TABLE invitations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
token TEXT NOT NULL UNIQUE,
email TEXT NOT NULL,
role TEXT NOT NULL DEFAULT 'user',
invited_by INTEGER REFERENCES users(id) ON DELETE SET NULL,
expires_at TEXT NOT NULL,
used_at TEXT,
created_at TEXT NOT NULL DEFAULT (datetime('now'))
)
`);
db.exec('CREATE INDEX IF NOT EXISTS idx_invitations_token ON invitations(token)');
console.log('[DB] Table invitations créée');
}
}
export default db;