From d0ded5cd9bf5070a120bad58b5be21fe2ac6a4ff Mon Sep 17 00:00:00 2001
From: C3032 <C3032@BC3032>
Date: 星期六, 20 十二月 2025 16:41:09 +0800
Subject: [PATCH] test
---
IDViewer_2D/User.cs | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/IDViewer_2D/User.cs b/IDViewer_2D/User.cs
new file mode 100644
index 0000000..c31e247
--- /dev/null
+++ b/IDViewer_2D/User.cs
@@ -0,0 +1,50 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SmartScanner
+{
+ public class User
+ {
+ public string Username { get; set; }
+ public string Password { get; set; }
+ public UserRole Role { get; set; }
+ }
+
+ public enum UserRole
+ {
+ Administrator,
+ Technician
+ }
+
+ public static class UserManager
+ {
+ public static List<User> UserList { get; } = new List<User>
+ {
+ new User { Username = "admin", Password = "123", Role = UserRole.Administrator },
+ //new User { Username = "admin2", Password = "admin456", Role = UserRole.Administrator },
+ //new User { Username = "tech1", Password = "tech123", Role = UserRole.Technician },
+ //new User { Username = "tech2", Password = "tech456", Role = UserRole.Technician }
+ };
+
+ public static User CurrentUser { get; private set; }
+
+ public static bool Authenticate(string username, string password)
+ {
+ var user = UserList.FirstOrDefault(u => u.Username == username && u.Password == password);
+ if (user != null)
+ {
+ CurrentUser = user;
+ return true;
+ }
+ return false;
+ }
+
+ public static bool HasAdministratorPrivilege()
+ {
+ return CurrentUser?.Role == UserRole.Administrator;
+ }
+ }
+}
--
Gitblit v1.9.3