diff options
author | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-25 08:21:01 -0400 |
---|---|---|
committer | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-25 08:21:01 -0400 |
commit | ffbe2870d320c4127d32307f2646f39e2e284eec (patch) | |
tree | f9f46447c689c1667f04f17bfbf2e8d07ff0fcd0 /ufund-api/src/main/java/com/ufund/api/ufundapi/controller/AuthController.java | |
parent | d31c1aec7f615646553a227c8e235d4ae2679c68 (diff) | |
parent | c15aa3daab0cf9a640945d4e634d1327fb55d2db (diff) | |
download | JellySolutions-ffbe2870d320c4127d32307f2646f39e2e284eec.tar.gz JellySolutions-ffbe2870d320c4127d32307f2646f39e2e284eec.tar.bz2 JellySolutions-ffbe2870d320c4127d32307f2646f39e2e284eec.zip |
Merge branch 'api-cleanup' of https://github.com/RIT-SWEN-261-02/team-project-2245-swen-261-02-2b into api-cleanup
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/controller/AuthController.java')
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/controller/AuthController.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/AuthController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/AuthController.java index b46d4ee..6ba6160 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/AuthController.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/AuthController.java @@ -2,6 +2,8 @@ package com.ufund.api.ufundapi.controller; import java.io.IOException; import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -17,6 +19,7 @@ import com.ufund.api.ufundapi.service.AuthService; @RestController @RequestMapping("auth") public class AuthController { + private static final Logger LOG = Logger.getLogger(AuthController.class.getName()); private final AuthService authService; public AuthController(AuthService authService) { @@ -32,14 +35,17 @@ public class AuthController { */ @PostMapping("") public ResponseEntity<String> login(@RequestBody Map<String, String> params) { + LOG.log(Level.INFO, "POST /auth body: {0}", params); String username = params.get("username"); String password = params.get("password"); try { String key = authService.login(username, password); return new ResponseEntity<>(key, HttpStatus.OK); - } catch (IllegalAccessException e) { + } catch (IllegalAccessException ex) { + LOG.log(Level.WARNING, ex.getLocalizedMessage()); return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); } catch (IOException ex) { + LOG.log(Level.SEVERE, ex.getLocalizedMessage()); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -52,10 +58,12 @@ public class AuthController { */ @DeleteMapping("") public ResponseEntity<Object> logout(@RequestHeader("jelly-api-key") String key) { + LOG.log(Level.INFO, "DELETE /auth key: {0}", key); try { authService.logout(key); return new ResponseEntity<>(HttpStatus.OK); - } catch (IOException e) { + } catch (IOException ex) { + LOG.log(Level.WARNING, ex.getLocalizedMessage()); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } } |