This commit is contained in:
wxt
2026-01-27 13:39:22 +08:00
3 changed files with 17 additions and 17 deletions

View File

@@ -41,12 +41,12 @@ namespace 全自动水压检测仪.DATA
try
{
// 删除现有的默认用户
connection.Execute("DELETE FROM sys_users WHERE username IN ('admin', 'cgx')");
connection.Execute("DELETE FROM sys_users WHERE username IN ('admin', 'csi')");
Debug.WriteLine("已删除现有默认用户");
// 重新创建
CreateUserIfNotExists(connection, "admin", "admin123", 1);
CreateUserIfNotExists(connection, "cgx", "123", 0);
CreateUserIfNotExists(connection, "csi", "123456", 0);
Debug.WriteLine("默认用户重置完成!");
}
@@ -120,8 +120,8 @@ namespace 全自动水压检测仪.DATA
// 创建默认管理员账户 admin / admin123
CreateUserIfNotExists(connection, "admin", "admin123", 1);
// 创建默认普通用户账户 cgx / 123
CreateUserIfNotExists(connection, "cgx", "123", 0);
// 创建默认普通用户账户 csi / 123456
CreateUserIfNotExists(connection, "csi", "123456", 0);
}
catch (Exception ex)
{

View File

@@ -87,7 +87,7 @@ namespace 全自动水压检测仪.DATA
connection.Open();
// 删除现有用户
connection.Execute("DELETE FROM sys_users WHERE username IN ('admin', 'cgx')");
connection.Execute("DELETE FROM sys_users WHERE username IN ('admin', 'csi')");
Debug.WriteLine("已删除现有默认用户");
// 重新创建 admin
@@ -101,12 +101,12 @@ namespace 全自动水压检测仪.DATA
// 重新创建 cgx
string salt2 = PasswordHelper.GenerateSalt();
string hash2 = PasswordHelper.HashPassword("123", salt2);
string hash2 = PasswordHelper.HashPassword("123456", salt2);
connection.Execute(@"
INSERT INTO sys_users (username, password_hash, salt, user_role, status, create_time)
VALUES (@username, @hash, @salt, @role, 1, NOW())",
new { username = "cgx", hash = hash2, salt = salt2, role = 0 });
Debug.WriteLine("✓ 创建普通用户: cgx / 123");
new { username = "csi", hash = hash2, salt = salt2, role = 0 });
Debug.WriteLine("✓ 创建普通用户: csi / 123456");
Debug.WriteLine("默认用户重置完成!");
}

View File

@@ -35,7 +35,7 @@ namespace 全自动水压检测仪
if (forceReset)
{
var result = MessageBox.Show(
"确定要重置默认用户吗?\n\n这将删除并重新创建\n• admin / admin123 (管理员)\n• cgx / 123 (普通用户)\n\n其他用户不受影响。",
"确定要重置默认用户吗?\n\n这将删除并重新创建\n• admin / admin123 (管理员)\n• csi / 123456 (普通用户)\n\n其他用户不受影响。",
"重置默认用户",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
@@ -44,7 +44,7 @@ namespace 全自动水压检测仪
{
DatabaseInitializer.Initialize();
DatabaseInitializer.ForceResetDefaultUsers();
MessageBox.Show("默认用户已重置!\n\n管理员: admin / admin123\n普通用户: cgx / 123",
MessageBox.Show("默认用户已重置!\n\n管理员: admin / admin123\n普通用户: csi / 123456",
"重置成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
return;
@@ -104,7 +104,7 @@ namespace 全自动水压检测仪
// 检查默认用户
var adminUser = userRepo.GetUserByUsername("admin");
var cgxUser = userRepo.GetUserByUsername("cgx");
var csiUser = userRepo.GetUserByUsername("csi");
bool needsReset = false;
@@ -147,11 +147,11 @@ namespace 全自动水压检测仪
}
// 检查 cgx 用户
if (cgxUser != null)
if (csiUser != null)
{
string storedPassword = cgxUser.PasswordHash ?? "";
string storedPassword = csiUser.PasswordHash ?? "";
System.Diagnostics.Debug.WriteLine($"\n检查 cgx 用户:");
System.Diagnostics.Debug.WriteLine($"\n检查 csi 用户:");
System.Diagnostics.Debug.WriteLine($" 当前密码值: '{storedPassword}'");
System.Diagnostics.Debug.WriteLine($" 密码长度: {storedPassword.Length}");
@@ -177,7 +177,7 @@ namespace 全自动水压检测仪
}
else
{
System.Diagnostics.Debug.WriteLine($"\ncgx 用户不存在");
System.Diagnostics.Debug.WriteLine($"\ncsi 用户不存在");
needsReset = true;
}
@@ -187,7 +187,7 @@ namespace 全自动水压检测仪
DatabaseInitializer.ForceResetDefaultUsers();
System.Diagnostics.Debug.WriteLine("密码数据已修复!");
System.Diagnostics.Debug.WriteLine(" admin 密码: admin123");
System.Diagnostics.Debug.WriteLine(" cgx 密码: 123");
System.Diagnostics.Debug.WriteLine(" csi 密码: 123456");
}
else
{