-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.cpp
More file actions
66 lines (59 loc) · 1.53 KB
/
Copy pathauth.cpp
File metadata and controls
66 lines (59 loc) · 1.53 KB
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
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <string>
#include <conio.h>
#include "admin_resto.h"
#include "loading.h"
using namespace std;
string data_login[2][3] = {{"admin", "123", "Admin"}, {"user", "123", "Operator"}};
string username, pass, level;
char ch;
void cek_authentication(string us, string pas);
int login()
{
system("cls");
cout << "===========================================================" << endl;
cout << "= >> LOGIN << =" << endl;
cout << "===========================================================" << endl;
cout << "\n\t\tUsername : ";
cin >> username;
cout << "\n\t\tPassword : ";
ch = _getch();
while (ch != 13)
{
pass.push_back(ch);
cout << '*';
ch = _getch();
}
cek_authentication(username, pass);
return 0;
}
void cek_authentication(string us, string pas)
{
for (int i = 0; i <= 1; i++)
{
// Cek inputan dengan data yang disimpan
if (data_login[i][0] == us && data_login[i][1] == pas)
{
// Menyimpan data dari array ke variabel level
level = data_login[i][2];
break;
}
}
if (level == "Admin")
{
system("cls");
getLoadingAdmin();
admin_resto();
}
else if (level == "Operator")
{
cout << "Anda login sebagi Operator";
}
else
{
cout << "\n Login gagal, username atau password salah";
cout << "\n Silahkan coba lagi ...";
getche();
login();
}
}