Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/COS301-SE-2023/InfoSafe into…
Browse files Browse the repository at this point in the history
… dev
  • Loading branch information
P3TROOS committed Oct 20, 2023
2 parents 66c7fdf + 57365dd commit b71825b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
@Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.asList("http://localhost:8080", "http://localhost:3000", "https://infosafe.live")); //""
configuration.setAllowedOrigins(Arrays.asList("https://infosafe.live", "http://localhost:3000", "https://infosafe.live")); //""
configuration.setAllowedMethods(Arrays.asList("*"));
configuration.setAllowedHeaders(Arrays.asList("*"));
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public List<AccessRequest> getAllAccessRequests() {
decryptedCurrentAssignee.setUser_id(currentAssignee.getUser_id());
decryptedCurrentAssignee.setFirst_name(encryptionService.decryptString(currentAssignee.getFirst_name()));
decryptedCurrentAssignee.setLast_name(encryptionService.decryptString(currentAssignee.getLast_name()));
decryptedCurrentAssignee.setEmail(currentAssignee.getEmail());
decryptedCurrentAssignee.setRole(currentAssignee.getRole());
accessRequest.setUser_id(decryptedCurrentAssignee);
}
Expand All @@ -77,7 +78,7 @@ public ResponseEntity<String> reviewAccessRequest(ReviewRequest reviewRequest) {
dataScope.getUsers().add(user);
dataScopeRepository.save(dataScope);
deleteService.deleteAccessRequestAndSaveToSecondary(reviewRequest.getRequest_id());
emailUser(reviewRequest.getUser_email(), dataScope.getDs_name(), "Approved");
emailUser(encryptionService.decryptString(reviewRequest.getUser_email()), dataScope.getDs_name(), "Approved");
notificationsService.makeNotification("Added to Datascope " + dataScope.getDs_name(), user);
return ResponseEntity.ok("given to user");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public List<AssetRequests> getAllAssetRequests() {
decryptedCurrentAssignee.setUser_id(currentAssignee.getUser_id());
decryptedCurrentAssignee.setFirst_name(encryptionService.decryptString(currentAssignee.getFirst_name()));
decryptedCurrentAssignee.setLast_name(encryptionService.decryptString(currentAssignee.getLast_name()));
decryptedCurrentAssignee.setEmail(currentAssignee.getEmail());
decryptedCurrentAssignee.setRole(currentAssignee.getRole());
assetRequests.setUser(decryptedCurrentAssignee);
}
Expand All @@ -88,14 +89,14 @@ public ResponseEntity<String> reviewAssetRequest(ReviewRequest reviewRequest) {
asset.setAvailability("No");
asset.setCurrent_assignee(user);
assetRepository.save(asset);
emailUser(reviewRequest.getUser_email(), asset.getAsset_name(), "Approved");
emailUser(encryptionService.decryptString(reviewRequest.getUser_email()), asset.getAsset_name(), "Approved");
notificationsService.makeNotification("Received Asset " + asset.getAsset_name(), user);
deleteService.deleteAssetRequestAndSaveToSecondary(reviewRequest.getRequest_id());
return ResponseEntity.ok("given to user");
}
} else {
deleteService.deleteAssetRequestAndSaveToSecondary(reviewRequest.getRequest_id());
emailUser(reviewRequest.getUser_email(), "", "Denied");
emailUser(encryptionService.decryptString(reviewRequest.getUser_email()), "", "Denied");
notificationsService.makeNotification("Asset Request Denied", userRepository.findByEmail(reviewRequest.getUser_email()).get());
return ResponseEntity.ok("rejected access");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public List<SupportRequest> getUserSupportRequests(int user_id) {
decryptedCurrentAssignee.setUser_id(currentAssignee.getUser_id());
decryptedCurrentAssignee.setFirst_name(encryptionService.decryptString(currentAssignee.getFirst_name()));
decryptedCurrentAssignee.setLast_name(encryptionService.decryptString(currentAssignee.getLast_name()));
decryptedCurrentAssignee.setEmail(currentAssignee.getEmail());
decryptedCurrentAssignee.setRole(currentAssignee.getRole());
supportRequest.setUser_id(decryptedCurrentAssignee);
}
Expand All @@ -132,12 +133,12 @@ public ResponseEntity<String> reviewSupportRequest(ReviewRequest reviewRequest)
if (dataScope.isPresent() && userOptional.isPresent()) {
dataScope.get().getUsers().add(userOptional.get());
deleteService.deleteSupportRequestAndSaveToSecondary(reviewRequest.getRequest_id());
emailUser(reviewRequest.getUser_email(), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Resolved");
emailUser(encryptionService.decryptString(reviewRequest.getUser_email()), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Resolved");
notificationsService.makeNotification("Support Request: ID " + reviewRequest.getRequest_id() + "Resolved", userOptional.get());
return ResponseEntity.ok("User given support to datascope");
} else {
deleteService.deleteSupportRequestAndSaveToSecondary(reviewRequest.getRequest_id());
emailUser(reviewRequest.getUser_email(), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Unsuccessful");
emailUser(encryptionService.decryptString(reviewRequest.getUser_email()), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Unsuccessful");
notificationsService.makeNotification("Support Request: ID " + reviewRequest.getRequest_id() + "Unsuccessful", userOptional.get());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("couldn't find datascope or user");
}
Expand All @@ -147,12 +148,12 @@ public ResponseEntity<String> reviewSupportRequest(ReviewRequest reviewRequest)
if (asset.isPresent() && userOptional.isPresent()) {
asset.get().setCurrent_assignee(userOptional.get());
deleteService.deleteSupportRequestAndSaveToSecondary(reviewRequest.getRequest_id());
emailUser(reviewRequest.getUser_email(), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Resolved");
emailUser(encryptionService.decryptString(reviewRequest.getUser_email()), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Resolved");
notificationsService.makeNotification("Support Request: ID " + reviewRequest.getRequest_id() + "Resolved", userOptional.get());
return ResponseEntity.ok("User given support to Asset");
} else {
deleteService.deleteSupportRequestAndSaveToSecondary(reviewRequest.getRequest_id());
emailUser(reviewRequest.getUser_email(), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Unsuccessful");
emailUser(encryptionService.decryptString(reviewRequest.getUser_email()), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Unsuccessful");
notificationsService.makeNotification("Support Request: ID " + reviewRequest.getRequest_id() + "Unsuccessful", userOptional.get());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("couldn't find asset or user");
}
Expand All @@ -162,12 +163,12 @@ public ResponseEntity<String> reviewSupportRequest(ReviewRequest reviewRequest)
if (task.isPresent() && userOptional.isPresent()) {
task.get().getUsers().add(userOptional.get());
deleteService.deleteSupportRequestAndSaveToSecondary(reviewRequest.getRequest_id());
emailUser(reviewRequest.getUser_email(), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Resolved");
emailUser(encryptionService.decryptString(reviewRequest.getUser_email()), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Resolved");
notificationsService.makeNotification("Support Request: ID " + reviewRequest.getRequest_id() + "Resolved", userOptional.get());
return ResponseEntity.ok("User given support to Task");
} else {
deleteService.deleteSupportRequestAndSaveToSecondary(reviewRequest.getRequest_id());
emailUser(reviewRequest.getUser_email(), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Unsuccessful");
emailUser(encryptionService.decryptString(reviewRequest.getUser_email()), reviewRequest.getRequest_id(), supportRequestRepository.findById(reviewRequest.getRequest_id()).get().getSupport_description(), "Unsuccessful");
notificationsService.makeNotification("Support Request: ID " + reviewRequest.getRequest_id() + "Unsuccessful", userOptional.get());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("couldn't find task or user");
}
Expand Down

0 comments on commit b71825b

Please sign in to comment.