Merge branch 'master' of http://192.168.0.115:8000/FullAutoWaterCheck
This commit is contained in:
@@ -41,12 +41,12 @@ namespace 全自动水压检测仪.DATA
|
|||||||
try
|
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("已删除现有默认用户");
|
Debug.WriteLine("已删除现有默认用户");
|
||||||
|
|
||||||
// 重新创建
|
// 重新创建
|
||||||
CreateUserIfNotExists(connection, "admin", "admin123", 1);
|
CreateUserIfNotExists(connection, "admin", "admin123", 1);
|
||||||
CreateUserIfNotExists(connection, "cgx", "123", 0);
|
CreateUserIfNotExists(connection, "csi", "123456", 0);
|
||||||
|
|
||||||
Debug.WriteLine("默认用户重置完成!");
|
Debug.WriteLine("默认用户重置完成!");
|
||||||
}
|
}
|
||||||
@@ -119,9 +119,9 @@ namespace 全自动水压检测仪.DATA
|
|||||||
|
|
||||||
// 创建默认管理员账户 admin / admin123
|
// 创建默认管理员账户 admin / admin123
|
||||||
CreateUserIfNotExists(connection, "admin", "admin123", 1);
|
CreateUserIfNotExists(connection, "admin", "admin123", 1);
|
||||||
|
|
||||||
// 创建默认普通用户账户 cgx / 123
|
// 创建默认普通用户账户 csi / 123456
|
||||||
CreateUserIfNotExists(connection, "cgx", "123", 0);
|
CreateUserIfNotExists(connection, "csi", "123456", 0);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace 全自动水压检测仪.DATA
|
|||||||
connection.Open();
|
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("已删除现有默认用户");
|
Debug.WriteLine("已删除现有默认用户");
|
||||||
|
|
||||||
// 重新创建 admin
|
// 重新创建 admin
|
||||||
@@ -101,12 +101,12 @@ namespace 全自动水压检测仪.DATA
|
|||||||
|
|
||||||
// 重新创建 cgx
|
// 重新创建 cgx
|
||||||
string salt2 = PasswordHelper.GenerateSalt();
|
string salt2 = PasswordHelper.GenerateSalt();
|
||||||
string hash2 = PasswordHelper.HashPassword("123", salt2);
|
string hash2 = PasswordHelper.HashPassword("123456", salt2);
|
||||||
connection.Execute(@"
|
connection.Execute(@"
|
||||||
INSERT INTO sys_users (username, password_hash, salt, user_role, status, create_time)
|
INSERT INTO sys_users (username, password_hash, salt, user_role, status, create_time)
|
||||||
VALUES (@username, @hash, @salt, @role, 1, NOW())",
|
VALUES (@username, @hash, @salt, @role, 1, NOW())",
|
||||||
new { username = "cgx", hash = hash2, salt = salt2, role = 0 });
|
new { username = "csi", hash = hash2, salt = salt2, role = 0 });
|
||||||
Debug.WriteLine("✓ 创建普通用户: cgx / 123");
|
Debug.WriteLine("✓ 创建普通用户: csi / 123456");
|
||||||
|
|
||||||
Debug.WriteLine("默认用户重置完成!");
|
Debug.WriteLine("默认用户重置完成!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace 全自动水压检测仪
|
|||||||
if (forceReset)
|
if (forceReset)
|
||||||
{
|
{
|
||||||
var result = MessageBox.Show(
|
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,
|
MessageBoxButtons.YesNo,
|
||||||
MessageBoxIcon.Question);
|
MessageBoxIcon.Question);
|
||||||
@@ -44,7 +44,7 @@ namespace 全自动水压检测仪
|
|||||||
{
|
{
|
||||||
DatabaseInitializer.Initialize();
|
DatabaseInitializer.Initialize();
|
||||||
DatabaseInitializer.ForceResetDefaultUsers();
|
DatabaseInitializer.ForceResetDefaultUsers();
|
||||||
MessageBox.Show("默认用户已重置!\n\n管理员: admin / admin123\n普通用户: cgx / 123",
|
MessageBox.Show("默认用户已重置!\n\n管理员: admin / admin123\n普通用户: csi / 123456",
|
||||||
"重置成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
"重置成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -104,7 +104,7 @@ namespace 全自动水压检测仪
|
|||||||
|
|
||||||
// 检查默认用户
|
// 检查默认用户
|
||||||
var adminUser = userRepo.GetUserByUsername("admin");
|
var adminUser = userRepo.GetUserByUsername("admin");
|
||||||
var cgxUser = userRepo.GetUserByUsername("cgx");
|
var csiUser = userRepo.GetUserByUsername("csi");
|
||||||
|
|
||||||
bool needsReset = false;
|
bool needsReset = false;
|
||||||
|
|
||||||
@@ -147,11 +147,11 @@ namespace 全自动水压检测仪
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查 cgx 用户
|
// 检查 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}'");
|
||||||
System.Diagnostics.Debug.WriteLine($" 密码长度: {storedPassword.Length}");
|
System.Diagnostics.Debug.WriteLine($" 密码长度: {storedPassword.Length}");
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ namespace 全自动水压检测仪
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine($"\ncgx 用户不存在");
|
System.Diagnostics.Debug.WriteLine($"\ncsi 用户不存在");
|
||||||
needsReset = true;
|
needsReset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ namespace 全自动水压检测仪
|
|||||||
DatabaseInitializer.ForceResetDefaultUsers();
|
DatabaseInitializer.ForceResetDefaultUsers();
|
||||||
System.Diagnostics.Debug.WriteLine("密码数据已修复!");
|
System.Diagnostics.Debug.WriteLine("密码数据已修复!");
|
||||||
System.Diagnostics.Debug.WriteLine(" admin 密码: admin123");
|
System.Diagnostics.Debug.WriteLine(" admin 密码: admin123");
|
||||||
System.Diagnostics.Debug.WriteLine(" cgx 密码: 123");
|
System.Diagnostics.Debug.WriteLine(" csi 密码: 123456");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user