- 최고관리자(Supervisor) 전용 2중 보안 잠금 시스템 및 인증 UI 적용 - 데이터베이스 인프라 및 암호화 마스터 키 자가 관리 기능 구축 - 권한 계층(Supervisor > Admin > User) 기반의 메뉴 노출 및 접근 제어 로직 강화 - 시스템 버전 정보 페이지 신규 추가 및 패키지 버전 자동 연동 (v0.2.5) - 사용자 관리 UI 디자인 개선 및 폰트/스타일 일원화
37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
const db = require('./db');
|
|
const crypto = require('crypto');
|
|
|
|
async function fixAdmin() {
|
|
try {
|
|
console.log('Altering table schema to include supervisor role...');
|
|
// First ensure the ENUM includes supervisor
|
|
await db.query("ALTER TABLE users MODIFY COLUMN role ENUM('supervisor', 'admin', 'user') DEFAULT 'user'");
|
|
|
|
const hashedPass = crypto.createHash('sha256').update('admin123').digest('hex');
|
|
console.log('Updating admin user...');
|
|
|
|
// Update both password and role for admin
|
|
const [result] = await db.query(
|
|
'UPDATE users SET password = ?, role = "supervisor" WHERE id = "admin"',
|
|
[hashedPass]
|
|
);
|
|
|
|
if (result.affectedRows > 0) {
|
|
console.log('✅ Admin user updated to Supervisor with password admin123');
|
|
} else {
|
|
console.log('⚠️ Admin user not found. Creating new admin...');
|
|
await db.query(
|
|
'INSERT INTO users (id, password, name, role, department, position) VALUES (?, ?, ?, ?, ?, ?)',
|
|
['admin', hashedPass, '시스템 관리자', 'supervisor', 'IT팀', '관리자']
|
|
);
|
|
console.log('✅ Admin user created as Supervisor with password admin123');
|
|
}
|
|
} catch (err) {
|
|
console.error('❌ Failed to fix admin user:', err);
|
|
} finally {
|
|
process.exit();
|
|
}
|
|
}
|
|
|
|
fixAdmin();
|