-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthManager.java
More file actions
54 lines (32 loc) · 1.3 KB
/
AuthManager.java
File metadata and controls
54 lines (32 loc) · 1.3 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
package oopprojecthalilkayra;
public class AuthManager {
public static boolean login(String username, String password) {
Database db = new Database();
User user = db.getUser(username);
if (user != null && user.getPassword().equals(password)) {
initializeActiveUser(user);
return true;
} else {
return false;
}
}
public static boolean register(String username, String name, String surname, String email, String password,
String homeAddress, String workAddress, java.util.Date dateOfBirth) {
Database db = new Database();
return db.addUser(username, name, surname, email, password, homeAddress, workAddress, dateOfBirth);
}
public static boolean initializeActiveUser(User user) {
Database db = new Database();
OopProjectHalilKayra.activeUser = user;
db.getActiveUserCart(user);
db.getActiveUserFavorites(user);
db.getActiveUserOrderedProducts(user);
db.getActiveUserCreditCards(user);
return true;
}
public static boolean isUserExist(String username) {
Database db = new Database();
User user = db.getUser(username);
return (user != null);
}
}