-
Notifications
You must be signed in to change notification settings - Fork 1
/
Auth.cs
55 lines (48 loc) · 1.55 KB
/
Auth.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
namespace EmployeeManagementSystem
{
internal class Auth
{
public static bool isLoggedIn;
public static User currentUser;
/*public static bool isUserEmp = false;
public static bool isUserAdmin = false;*/
public static bool Login()
{
Console.Clear();
Console.Write("Username: ");
string username = Console.ReadLine().Trim().ToLower();
Console.WriteLine(Environment.NewLine);
Console.Write("Password: ");
string password = Console.ReadLine().Trim();
Console.WriteLine(Environment.NewLine);
// Check if the username and password match any employee in the employee list
foreach (User i in Program.userList.GetAllUsers())
{
if (i.Username == username && i.Password == password)
{
currentUser = i;
return true;
}
}
isLoggedIn = true;
// If the username and password do not match any admin or employee, authentication fails
return false;
}
public static void Logout()
{
RulesView rulesView = new RulesView();
isLoggedIn = false;
currentUser = null;
rulesView.Show();
//Program.mainView()
}
public bool IsLoggedIn()
{
return isLoggedIn;
}
public static bool isUserAdmin()
{
return currentUser.IsAdmin;
}
}
}