-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_logowanie.cpp
101 lines (84 loc) · 2.58 KB
/
main_logowanie.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
using namespace std;
const int MaxWords = 100;
class User {
public:
string name;
string surname;
string adres;
string id_number;
string email;
string username;
string password;
User(string nam, string surnam, string adr, string id, string mail, string uname, string pwd) {
name = nam;
surname = surnam;
id_number = id;
adres = adr;
username = uname;
password = pwd;
email = mail;
}
User() {
name = "";
surname = "";
id_number = "";
adres = "";
username = "";
password = "";
email = "";
}
void displayUser() {
cout << "----------------------------------------------\nSzczegóły konta:" << endl;
cout << "Imie: " << name << endl;
cout << "Nazwisko: " << surname << endl;
cout << "PESEL: " << id_number << endl;
cout << "Adres: " << adres << endl;
cout << "Nazwa uzytkownika: " << username << endl;
cout << "Adres email: " << email << endl;
}
};
vector<User> UploadAllUsers() {
vector<User> UserData;
User buff;
const string filename = "C:\\Users\\alicj\\OneDrive\\Pulpit\\projektIO\\dane_pacjentow.txt";
ifstream file(filename);
if (!file.is_open()) {
cout << "Nie mozna otworzyc pliku." << endl;
exit(0);
}
else {
while (UserData.size() < MaxWords && file >> buff.email >> buff.password) {
UserData.push_back(buff);
}
file.close();
}
return UserData;
}
User insertData() {
vector<User> users = UploadAllUsers();
string username, password, email, name, surname, adres, id;
cout << "\n\nWprowadz dane: " << endl;
cout << "Podaj nazwe uzytkownika: ";
getline(cin, username);
cout << "Podaj haslo: ";
getline(cin, password);
for (const auto &user : users) {
if (user.username == username && user.password == password) {
cout << "Logowanie udane! Witaj, " << username << "." << endl;
return user;
}
}
cout << "Nieprawidlowa nazwa uzytkownika lub haslo. Sprobuj ponownie." << endl;
insertData();
}
int main() {
cout << "\n---------------------------------------------------\nLOGOWANIE DO SYSTEMU\n---------------------------------------------------" << endl;
User loggedInUser = insertData();
loggedInUser.displayUser();
return 0;
}