diff options
author | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-24 21:17:33 -0400 |
---|---|---|
committer | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-24 21:17:33 -0400 |
commit | cb3b7710b9e32df408b3a38383aca049fa98214e (patch) | |
tree | 38bbfe093fe6b397dd5f378c77e56f581058753b /ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java | |
parent | 35d7c971ed47718d4dc5738edb09d62cd780dac4 (diff) | |
download | JellySolutions-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/service/AuthService.java')
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java | 26 |
1 files changed, 17 insertions, 9 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 87a16a6..71b8f41 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 @@ -1,11 +1,12 @@ package com.ufund.api.ufundapi.service; +import java.io.IOException; + +import org.springframework.stereotype.Component; + import com.ufund.api.ufundapi.model.User; import com.ufund.api.ufundapi.model.UserAuth; import com.ufund.api.ufundapi.persistence.UserAuthDAO; -import org.springframework.stereotype.Component; - -import java.io.IOException; @Component public class AuthService { @@ -30,12 +31,19 @@ public class AuthService { if (userAuth == null) { throw new IllegalAccessException("Unauthenticated"); } -// -// var username = userAuth.getUsername(); -// var userType = userService.getUser(username).getType(); -// if (!username.equals(targetUsername) && userType != User.UserType.MANAGER) { -// throw new IllegalAccessException("Unauthorized"); -// } + + var username = userAuth.getUsername(); + var userType = userService.getUser(username).getType(); + if (!username.equals(targetUsername) && userType != User.UserType.MANAGER) { + throw new IllegalAccessException("Unauthorized"); + } + } + + public void authenticate(String key) throws IOException, IllegalAccessException { + var userAuth = userAuthDAO.getUserAuth(key); + if (userAuth == null) { + throw new IllegalAccessException("Unauthenticated"); + } } /** |