aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api/ufundapi/model
diff options
context:
space:
mode:
authorGunther6070 <haydenhartman10@yahoo.com>2025-03-24 21:17:33 -0400
committerGunther6070 <haydenhartman10@yahoo.com>2025-03-24 21:17:33 -0400
commitcb3b7710b9e32df408b3a38383aca049fa98214e (patch)
tree38bbfe093fe6b397dd5f378c77e56f581058753b /ufund-api/src/main/java/com/ufund/api/ufundapi/model
parent35d7c971ed47718d4dc5738edb09d62cd780dac4 (diff)
downloadJellySolutions-cb3b7710b9e32df408b3a38383aca049fa98214e.tar.gz
JellySolutions-cb3b7710b9e32df408b3a38383aca049fa98214e.tar.bz2
JellySolutions-cb3b7710b9e32df408b3a38383aca049fa98214e.zip
Fixed various bugs and began fixing auth system. Also started implementing checkout method in cupboardService
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/model')
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java8
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/model/User.java17
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/model/UserAuth.java7
3 files changed, 27 insertions, 5 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java
index c0e9214..22e86e3 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java
@@ -17,14 +17,14 @@ public class Need {
@JsonProperty("current") private double current;
/**
- * Create a new need
+ * Create a new need, used by the controller
*
* @param name The name of the need
* @param id The unique ID of the need
* @param maxGoal The maximum goal for this need
* @param type The type of need (monetary, physical)
*/
- public Need(@JsonProperty("name") String name, @JsonProperty("id") int id, @JsonProperty("maxGoal") double maxGoal, GoalType type) {
+ public Need(@JsonProperty("name") String name, @JsonProperty("id") int id, @JsonProperty("maxGoal") double maxGoal, @JsonProperty("type") GoalType type) {
this.id = id;
this.name = name;
this.maxGoal = maxGoal;
@@ -86,6 +86,10 @@ public class Need {
this.current = current;
}
+ public void incrementCurrent(double incrementAmount) {
+ this.current += incrementAmount;
+ }
+
public void setFilterAttributes(String[] filterAttributes) {
this.filterAttributes = filterAttributes;
}
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/User.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/User.java
index 6de1a8a..2871916 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/User.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/User.java
@@ -43,10 +43,21 @@ public class User {
return username;
}
+ /**
+ * Verifies if the provided password's hash is the same as the user's actual hash
+ *
+ * @param password The password to check if valid
+ * @return True or false depending on if it's equal
+ */
public boolean verifyPassword(String password) {
return password.hashCode() == passwordHash;
}
+ /**
+ * Adds a need's ID to a user's basket
+ *
+ * @param need The need to add
+ */
public void addToBasket(Need need) {
basket.add(need.getId());
}
@@ -59,6 +70,11 @@ public class User {
return basket.remove(needID);
}
+ /**
+ * Returns a user without a password hash for security purposes
+ *
+ * @return new User with empty password hash
+ */
public User withoutPasswordHash() {
return new User(this.username, 0, this.basket, this.type);
}
@@ -71,6 +87,7 @@ public class User {
this.passwordHash = other.passwordHash;
}
+ @Override
public String toString() {
return this.username + "; basket: " + this.basket + "; type:" + this.type + "; hash: " + this.passwordHash;
}
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/UserAuth.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/UserAuth.java
index 1c11a28..78dccec 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/UserAuth.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/UserAuth.java
@@ -1,10 +1,10 @@
package com.ufund.api.ufundapi.model;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
import java.time.LocalDateTime;
import java.util.UUID;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
public class UserAuth {
@JsonProperty("key") String key;
@JsonProperty("username") String username;
@@ -12,12 +12,13 @@ public class UserAuth {
public UserAuth(@JsonProperty("key") String key, @JsonProperty("username") String username, @JsonProperty("expiration") LocalDateTime expiration) {
this.key = key;
- this.expiration = expiration;
this.username = username;
+ this.expiration = expiration;
}
/**
* Generate a new user authentication profile
+ *
* @param username the username the key will belong to
* @return The new user authentication profile
*/