aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api/ufundapi/service
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/service')
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java8
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java6
2 files changed, 7 insertions, 7 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java
index 71b8f41..4e5ebce 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java
@@ -29,20 +29,20 @@ public class AuthService {
public void authenticate(String targetUsername, String key) throws IllegalAccessException, IOException {
var userAuth = userAuthDAO.getUserAuth(key);
if (userAuth == null) {
- throw new IllegalAccessException("Unauthenticated");
+ throw new IllegalAccessException("Invalid authentication key");
}
var username = userAuth.getUsername();
var userType = userService.getUser(username).getType();
if (!username.equals(targetUsername) && userType != User.UserType.MANAGER) {
- throw new IllegalAccessException("Unauthorized");
+ throw new IllegalAccessException("Provided key does not grant access to perform the requested operation");
}
}
public void authenticate(String key) throws IOException, IllegalAccessException {
var userAuth = userAuthDAO.getUserAuth(key);
if (userAuth == null) {
- throw new IllegalAccessException("Unauthenticated");
+ throw new IllegalAccessException("Invalid authentication key");
}
}
@@ -58,7 +58,7 @@ public class AuthService {
public String login(String username, String password) throws IllegalAccessException, IOException {
var usr = userService.getUser(username);
if (usr == null || !usr.verifyPassword(password)) {
- throw new IllegalAccessException("Unauthorized");
+ throw new IllegalAccessException("Incorrect username or password");
}
var userAuth = UserAuth.generate(username);
userAuthDAO.addUserAuth(userAuth);
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
index 8713882..91e3ba5 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
@@ -104,12 +104,12 @@ public class CupboardService {
*
* @param id The ID of the need to update
* @param checkoutAmount The amount to update the need by
- * @throws IOException
- * @throws IllegalAccessException
+ * @throws IOException If there is an error reading the file
+ * @throws IllegalAccessException If the user has insufficient permission
*/
public void checkoutNeed(int id, double checkoutAmount, String key) throws IOException, IllegalAccessException {
if (checkoutAmount <= 0) {
- throw new IllegalArgumentException("Amount must be greather than 0");
+ throw new IllegalArgumentException("Amount must be greater than 0");
}
authService.authenticate(key);
Need need = cupboardDAO.getNeed(id);