Files
BetterDesk/web-nodejs/reset-password.js
T
UNITRONIX 8d952e4ba1 Add password auth helpers; remove legacy dev scripts
Add a new auth package implementing password hashing/verification (PBKDF2-HMAC-SHA256), a random-string generator, and unit tests. Update .gitignore to catch additional sensitive filenames and to ignore legacy dev scripts, migrations, templates and build artifacts. Remove many legacy/dev helper scripts (dev_modules/, scripts/legacy/, build_windows.sh, migrations/, templates/) and add web-nodejs reset-password scripts and a session secret placeholder. Changes consolidate authentication utilities and clean up old/unused development tooling and noise in the repo.
2026-03-02 07:59:24 +01:00

30 lines
1022 B
JavaScript

const bcrypt = require('./node_modules/bcrypt');
const Database = require('better-sqlite3');
const DB_PATH = process.env.DB_PATH || '/opt/rustdesk/db_v2.sqlite3';
const NEW_PASSWORD = process.argv[2] || 'admin';
async function resetPassword() {
const hash = await bcrypt.hash(NEW_PASSWORD, 12);
const db = new Database(DB_PATH);
const result = db.prepare('UPDATE users SET password_hash = ? WHERE username = ?').run(hash, 'admin');
if (result.changes > 0) {
console.log('Password reset successful!');
console.log('Username: admin');
console.log('Password:', NEW_PASSWORD);
} else {
console.log('No admin user found, creating one...');
db.prepare('INSERT INTO users (username, password_hash, role) VALUES (?, ?, ?)').run('admin', hash, 'admin');
console.log('Admin user created!');
console.log('Username: admin');
console.log('Password:', NEW_PASSWORD);
}
db.close();
}
resetPassword().catch(console.error);