Skip to content

Commit befa38f

Browse files
committed
added password to field UserLoginResponseModel
1 parent 9ff1748 commit befa38f

File tree

8 files changed

+34
-28
lines changed

8 files changed

+34
-28
lines changed

src/data/FlashcardSets.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
title,description,isPrivate,flashcardSetId,ownerUsername,flashcardIds
22
test set 1,for testing study use case,false,0,testUser,0,1,2,3
33
empty test set,for testing study use case with empty set,true,1,testUser
4+
my flashcard set,for presentation,false,2,lucas,4

src/data/Flashcards.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ test card 1,the first test card,2022-11-13T15:32:26.666982800,0,0
33
test card 2,the second test card,2022-11-13T15:32:27.666982800,1,0
44
test card 3,the third test card,2022-11-13T15:32:28.666982800,2,0
55
alphabetical order checker,to test if alphabetical order is working,2022-11-13T15:32:29.666982800,3,0
6+
my new flashcard,my test definition,2022-11-21T14:27:10.045791,4,2

src/data/Users.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
username,password,isAdmin,flashcardSetIds
22
jempio,ilovejempio,false
33
ducas,badpassword,false
4+
lucas,password,false,2
5+
adminUser,password,true
46
testUser,password,false,0,1

src/main/java/MainPage/HomePage.java

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
import create_flashcardset_use_case.*;
44
import dataAccess.*;
55
import entities.FlashcardSetFactory;
6+
import loginAndSignupUseCase.UserLoginInputBoundary;
7+
import loginAndSignupUseCase.UserLoginInteractor;
8+
import loginAndSignupUseCase.UserLoginOutputBoundary;
69
import loginAndSignupUseCase.UserLoginResponseModel;
10+
import loginAndSignupUseCase.loginAndSignupUseCaseScreens.UserLoginController;
11+
import loginAndSignupUseCase.loginAndSignupUseCaseScreens.UserLoginPresenter;
712
import loginAndSignupUseCase.loginAndSignupUseCaseScreens.WelcomeScreen;
813
import search_use_case.*;
914

1015
import javax.swing.*;
1116
import java.awt.*;
1217
import java.io.IOException;
13-
import java.util.HashMap;
1418
import java.util.Map;
1519

1620
public class HomePage extends JFrame {
@@ -94,30 +98,21 @@ public HomePage(UserLoginResponseModel user) throws IOException {
9498
}
9599

96100

97-
private void refresh() {
101+
private void refresh(UserLoginResponseModel user) {
98102
try {
99-
// UserLoginOutputBoundary presenter = new UserLoginPresenter();
100-
// UserLoginInputBoundary interactor = new UserLoginInteractor(
101-
// gateway, presenter);
102-
// UserLoginController userLoginController = new UserLoginController(interactor);
103-
// setVisible(false);
104-
// dispose();
105-
// new LoginScreen(userLoginController).setVisible(true);
106-
//
107-
// UserLoginResponseModel user = userLoginController.create(user.getSignedInUsername(),
108-
// user.getPassword());
109-
// this.dispose();
103+
UserLoginOutputBoundary presenter = new UserLoginPresenter();
104+
UserLoginInputBoundary interactor = new UserLoginInteractor(
105+
gateway, presenter);
106+
UserLoginController userLoginController = new UserLoginController(interactor);
107+
setVisible(false);
108+
dispose();
109+
110+
user = userLoginController.create(user.getSignedInUsername(),
111+
user.getPassword());
112+
this.dispose();
110113
new HomePage(user);
111114
} catch (Exception e) {
112115
JOptionPane.showMessageDialog(this, e.getMessage());
113116
}
114117
}
115-
public static void main(String[] args) throws IOException {
116-
Map<Integer, String[]> map = new HashMap<>();
117-
for (int i = 1; i < 4; i++) {
118-
map.put(i, new String[]{"test set " + i, "test description " + i});
119-
}
120-
UserLoginResponseModel user = new UserLoginResponseModel("Lucas", false, map);
121-
new HomePage(user);
122-
}
123118
}

src/main/java/loginAndSignupUseCase/UserLoginInteractor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public UserLoginResponseModel login(UserLoginRequestModel userLoginRequestModel)
3030

3131

3232
UserLoginResponseModel accountResponseModel = new UserLoginResponseModel(tempUser.getUsername(),
33+
tempUser.getPassword(),
3334
tempUser.getIsAdmin(), flashcardSets);
3435
return userLoginOutputBoundary.prepareSuccessView(accountResponseModel);
3536
}
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package loginAndSignupUseCase;
22

3-
import java.util.HashMap;
43
import java.util.Map;
54

65
public class UserLoginResponseModel {
7-
String username;
6+
private final String username;
87

9-
boolean isAdmin;
8+
private final String password;
9+
private final boolean isAdmin;
1010

11-
Map<Integer, String[]> flashcardSets;
11+
private final Map<Integer, String[]> flashcardSets;
1212

13-
public UserLoginResponseModel(String loggedInUsername, boolean isAdmin, Map<Integer, String[]> flashcardSets){
13+
public UserLoginResponseModel(String loggedInUsername, String password,
14+
boolean isAdmin, Map<Integer, String[]> flashcardSets){
1415
this.username = loggedInUsername;
16+
this.password = password;
1517
this.isAdmin = isAdmin;
1618
this.flashcardSets = flashcardSets;
1719
}
@@ -24,4 +26,8 @@ public String getSignedInUsername() {
2426
public Map<Integer, String[]> getFlashcardSets(){
2527
return flashcardSets;
2628
}
29+
30+
public String getPassword() {
31+
return password;
32+
}
2733
}

src/main/java/loginAndSignupUseCase/loginAndSignupUseCaseScreens/UserLoginController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public UserLoginController(UserLoginInputBoundary loginGateway) {
1717
* @param password The password used to log in
1818
* @return The response given by the interactor object.
1919
*/
20-
UserLoginResponseModel create(String username, String password) {
20+
public UserLoginResponseModel create(String username, String password) {
2121
UserLoginRequestModel requestModel = new UserLoginRequestModel(username, password);
2222
return userInput.login(requestModel);
2323
}

src/main/java/searchTestMain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static void main(String[] args) throws IOException {
2222
SearchOutputBoundary search_presenter = new SearchPresenter();
2323
SearchInputBoundary search_interactor = new SearchInteractor(search_presenter, dbGateway);
2424
SearchController search_controller = new SearchController(search_interactor);
25-
UserLoginResponseModel user = new UserLoginResponseModel("jempio",
25+
UserLoginResponseModel user = new UserLoginResponseModel("jempio", "ilovejempio",
2626
true, new HashMap<>());
2727

2828
DBGateway gateway = new DBGateway(flashcardGateway, flashcardSetGateway, null);

0 commit comments

Comments
 (0)