Files
vue-pult/server/add-test-user.js
sasha 3e90269b0b Initial commit: Vue.js тир управления система
- Клиентская часть Vue 3 + Vite
- Серверная часть Node.js + WebSocket
- Система авторизации и смен
- Управление игровыми портами
- Поддержка тем (светлая/темная)
- Адаптивный дизайн

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-19 12:24:22 +03:00

70 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const fs = require('node:fs/promises');
const crypto = require('crypto');
const path = require('path');
// Функция хеширования паролей как в системе
function hashPassword(password) {
// Шаг 1: MD5 от пароля
const firstHash = crypto.createHash('md5').update(password).digest('hex');
// Шаг 2: MD5 от (первый_хэш + "pult2024")
const finalHash = crypto.createHash('md5').update(firstHash + "pult2024").digest('hex');
return finalHash;
}
async function addTestUser() {
try {
// Читаем текущий файл пользователей
const avtPath = path.join(__dirname, 'data/avt.ini');
const avtData = await fs.readFile(avtPath, 'utf8');
const avt = JSON.parse(avtData);
console.log('Текущие пользователи:', Object.keys(avt));
// Добавляем тестового пользователя
const testPhone = '79999999999';
const testPassword = '12345';
avt[testPhone] = {
"_id": 999,
"cdata": Date.now() / 1000,
"pass": hashPassword(testPassword),
"tel": parseInt(testPhone),
"group": 3,
"color": "#00ff00",
"fio": "Тестовый Пользователь",
"groupz": {
"_id": 3,
"name": "Программист",
"access": {
"fullaccess": {},
"user": {},
"admin": {
"egroup": [40, 50, 60, 70]
}
},
"color": "5235bb"
},
"access": {
"fullaccess": {},
"user": {},
"admin": {
"egroup": [40, 50, 60, 70]
}
},
"taccess": "operators"
};
// Сохраняем обновленный файл
await fs.writeFile(avtPath, JSON.stringify(avt, null, 2));
console.log('✅ Тестовый пользователь добавлен:');
console.log('Телефон:', testPhone);
console.log('Пароль:', testPassword);
console.log('Хеш пароля:', hashPassword(testPassword));
} catch (error) {
console.error('Ошибка:', error);
}
}
addTestUser();