Files
dwroller/database/scripts/reset_pw_andreas_chris.js
T
alex dde3abda55 feat: Add validation and normalization utilities for player records
- Implemented `validatePlayer` and `normalizeTabInfo` functions in `database/validate.js` for player data validation and normalization.
- Added error handling for required fields and enforced data types and constraints.
- Introduced standardization for characteristics and skills.

feat: Create script for extracting rules from PDF files

- Developed `extract-rules.js` to extract text from PDF rulebooks and categorize rules.
- Integrated `pdftotext` for PDF processing and created a searchable rules database.
- Implemented rule categorization and indexing for efficient searching.

feat: Implement RulesTab component for rule searching

- Created `RulesTab.jsx` for searching and displaying rules with filtering options.
- Added recent searches and quick reference buttons for user convenience.
- Integrated API calls for fetching rules and displaying results dynamically.

feat: Add test script for Rules API

- Created `test-rules.js` to test the functionality of the Rules API endpoints.
- Included tests for search and stats endpoints to ensure proper response handling.
2025-08-16 12:15:32 +02:00

36 lines
1.5 KiB
JavaScript

const fs = require('fs');
const path = require('path');
const bcrypt = require('bcrypt');
const { playerHelpers } = require('../sqlite-db');
(async function main(){
const names = ['andreas','chris'];
const backupsDir = path.join(__dirname, '..', 'backups');
if (!fs.existsSync(backupsDir)) fs.mkdirSync(backupsDir, { recursive: true });
const ts = Date.now();
for (const name of names) {
const player = playerHelpers.getByName(name);
if (!player) {
console.log('Player not found, skipping:', name);
continue;
}
const beforePath = path.join(backupsDir, `${name}.pw.before.${ts}.json`);
fs.writeFileSync(beforePath, JSON.stringify(player, null, 2), 'utf8');
console.log('Backup written:', beforePath);
const plain = '1234';
const hash = await bcrypt.hash(plain, 10);
const ok = playerHelpers.update(name, { name, rollerInfo: player.rollerInfo || {}, shopInfo: player.shopInfo || {}, tabInfo: player.tabInfo || {}, pw: '', pwHash: hash });
if (!ok) {
console.error('Failed to update pw for', name);
continue;
}
const updated = playerHelpers.getByName(name);
const afterPath = path.join(backupsDir, `${name}.pw.after.${ts}.json`);
fs.writeFileSync(afterPath, JSON.stringify(updated, null, 2), 'utf8');
console.log('Updated player:', name, 'pwHash set. After backup:', afterPath);
console.log(JSON.stringify({ name: updated.name, pwHashPresent: !!updated.pwHash, _id: updated._id }, null, 2));
}
console.log('All done. Password for andreas and chris set to "1234" (hashed).');
})();