diff --git a/src/main/java/screens/user_registration_screen/UserRegistrationUI.java b/src/main/java/screens/user_registration_screen/UserRegistrationUI.java index 2872a5f6..34ff2a24 100644 --- a/src/main/java/screens/user_registration_screen/UserRegistrationUI.java +++ b/src/main/java/screens/user_registration_screen/UserRegistrationUI.java @@ -86,7 +86,7 @@ public void getUserCredentials(){ } public static void main(String[] args){ - Database testDB = new UserDatabase(new File("newAccounts23")); + Database testDB = new UserDatabase(new File("new")); UserLoginInteractor2 userLoginInteractor2 = new UserLoginInteractor2(testDB, new UserChatsPresenter()); UserLoginPresenter userLoginPresenter = new UserLoginPresenter(testDB, userLoginInteractor2); UserVerificationOutputView loginUI = new UserLoginUI(userLoginPresenter); diff --git a/src/main/java/use_cases/user_login_use_cases/UserLoginInteractor2.java b/src/main/java/use_cases/user_login_use_cases/UserLoginInteractor2.java index 132d613c..6198156b 100644 --- a/src/main/java/use_cases/user_login_use_cases/UserLoginInteractor2.java +++ b/src/main/java/use_cases/user_login_use_cases/UserLoginInteractor2.java @@ -1,15 +1,17 @@ package use_cases.user_login_use_cases; import data_access.Database; +import entities.chat.Chat; import entities.user_entities.User; import java.util.ArrayList; +import java.util.List; public class UserLoginInteractor2 implements UserLoginInputBoundary { private final UserLoginOutputBoundary chatPresenter; private final Database database; - private User user; + private final List chatsStrings = new ArrayList<>(); public UserLoginInteractor2(Database database, UserLoginOutputBoundary chatPresenter){ this.database = database; @@ -20,8 +22,19 @@ public UserLoginInteractor2(Database database, UserLoginOutputBoundary chatPrese public void login(String username, String password) { //will update this.chatPresenter //TODO: change below, as its just temporary - user = database.getUser(username); - + try { + User user = database.getUser(username); + this.chatPresenter.setPasswordNotMatched(!user.PasswordMatch(password)); + this.chatPresenter.setUserNotExists(false); + List chats = user.getChats(); + for(Chat chat: chats){ + this.chatsStrings.add(chat.getName()); + } + this.chatPresenter.setChats(this.chatsStrings); + }catch(NullPointerException e){ + this.chatPresenter.setUserNotExists(true); + this.chatPresenter.setChats(this.chatsStrings); + } } diff --git a/src/test/java/test_user_login/TestUserLoginInteractor.java b/src/test/java/test_user_login/TestUserLoginInteractor.java new file mode 100644 index 00000000..c14c3c93 --- /dev/null +++ b/src/test/java/test_user_login/TestUserLoginInteractor.java @@ -0,0 +1,5 @@ +package test_user_login; + +public class TestUserLoginInteractor { + +} diff --git a/src/test/java/test_user_login/TestUserLoginPresenter.java b/src/test/java/test_user_login/TestUserLoginPresenter.java new file mode 100644 index 00000000..bf149dff --- /dev/null +++ b/src/test/java/test_user_login/TestUserLoginPresenter.java @@ -0,0 +1,4 @@ +package test_user_login; + +public class TestUserLoginPresenter { +}