diff --git a/src/main/java/org/lab41/dendrite/web/controller/BranchController.java b/src/main/java/org/lab41/dendrite/web/controller/BranchController.java index bc2eeaa..915c664 100644 --- a/src/main/java/org/lab41/dendrite/web/controller/BranchController.java +++ b/src/main/java/org/lab41/dendrite/web/controller/BranchController.java @@ -22,6 +22,8 @@ import org.springframework.core.task.TaskExecutor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.PathVariable; @@ -355,6 +357,8 @@ public ResponseEntity> getCurrentBranch(@PathVariable String @RequestMapping(value = "/projects/{projectId}/current-branch/commit", method = RequestMethod.POST) public ResponseEntity> commitBranch(@PathVariable String projectId) throws GitAPIException, IOException { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + Map response = new HashMap<>(); MetaGraphTx tx = metaGraphService.newTransaction(); @@ -381,7 +385,7 @@ public ResponseEntity> commitBranch(@PathVariable String pro Git git = historyService.projectGitRepository(projectMetadata); try { git.commit() - .setAuthor("user", "user@example.com") + .setAuthor(authentication.getName(), "") .setMessage("commit") .call(); } finally { diff --git a/src/main/java/org/lab41/dendrite/web/controller/GraphExportController.java b/src/main/java/org/lab41/dendrite/web/controller/GraphExportController.java index da257ba..7250103 100644 --- a/src/main/java/org/lab41/dendrite/web/controller/GraphExportController.java +++ b/src/main/java/org/lab41/dendrite/web/controller/GraphExportController.java @@ -36,6 +36,8 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.PathVariable; @@ -118,6 +120,7 @@ public ResponseEntity export(@PathVariable String graphId, public ResponseEntity> save(@PathVariable String graphId, @Valid GraphExportBean item, BindingResult result) throws IOException, GitAPIException { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); Map response = new HashMap<>(); @@ -180,7 +183,7 @@ public ResponseEntity> save(@PathVariable String graphId, .call(); git.commit() - .setAuthor("user", "user@example.com") + .setAuthor(authentication.getName(), "") .setMessage("commit") .call(); } finally {