初始提交:DSH 多租户平台(dshs)

This commit is contained in:
admin committed 2026-09-13 16:18:10 +08:00
commit 43976fea6a
167 files changed
+24456

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
const crypto = require('crypto');
const Database = require('/opt/dshs/node_modules/better-sqlite3');
const db = new Database('/var/lib/dshs/dshs.db');
const admin = db.prepare('SELECT id FROM users WHERE role=? LIMIT 1').get('admin');
const token = crypto.randomBytes(32).toString('hex');
const hash = crypto.createHash('sha256').update(token).digest('hex');
db.prepare('INSERT INTO sessions (token_hash,user_id,created_at,expires_at,ip,user_agent) VALUES (?,?,?,?,?,?)').run(hash, admin.id, Date.now(), Date.now() + 600 * 1000, '127.0.0.1', 'poc-curl2');
console.log(token);
db.close();