From bb9ce55cb5b55a6aaed2399e39a01d68f2491ce3 Mon Sep 17 00:00:00 2001
From: sowgro <tpoke.ferrari@gmail.com>
Date: Thu, 6 Mar 2025 21:41:39 -0500
Subject: Push current changes (working on documentation and tests)

---
 .../api/ufundapi/persistence/UserAuthFIleDAO.java  | 27 +++++++++++++++-------
 1 file changed, 19 insertions(+), 8 deletions(-)

(limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java')

diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java
index 67918cc..4494939 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java
@@ -24,6 +24,11 @@ public class UserAuthFIleDAO implements UserAuthDAO {
         load();
     }
 
+    /**
+     * Loads the data from the file into the map
+     *
+     * @throws IOException Thrown if there was an issue reading the file
+     */
     private void load() throws IOException {
         userAuthMap.clear();
 
@@ -34,29 +39,35 @@ public class UserAuthFIleDAO implements UserAuthDAO {
         }
     }
 
+    /**
+     * Saves the data from the map into the json file
+     *
+     * @throws IOException Thrown on any problem writing the file
+     */
     private void save() throws IOException {
         objectMapper.writeValue(new File(filename), userAuthMap.values());
     }
 
-    public UserAuth[] getAuthKeys() {
+    @Override
+    public UserAuth getUserAuth(String key) {
         synchronized (userAuthMap) {
-            return userAuthMap.values().toArray(UserAuth[]::new);
+            return userAuthMap.get(key);
         }
     }
 
     @Override
-    public UserAuth getUserAuth(String key) {
+    public void addUserAuth(UserAuth userAuth) throws IOException {
         synchronized (userAuthMap) {
-            return userAuthMap.get(key);
+            userAuthMap.put(userAuth.getKey(), userAuth);
         }
+        save();
     }
 
     @Override
-    public boolean addUserAuth(UserAuth userAuth) throws IOException {
+    public void removeUserAuth(String key) throws IOException {
         synchronized (userAuthMap) {
-            userAuthMap.put(userAuth.getKey(), userAuth);
-            save();
-            return true;
+            userAuthMap.remove(key);
         }
+        save();
     }
 }
-- 
cgit v1.2.3