Skip to content

Commit 1fbac86

Browse files
committed
Set the CurrentUser when doing imports
The `Import()` extension method provided by the Data Transfer Library doesn't have access to the `HttpContext` and, thus, can't set the `LastModifiedBy` to the current user if that option is selected via the editor (see #5361a8e). This can be mitigated by injecting that value into the `ImportOptions` object prior to import. Note that this behavior is by design, but it does require this configuration from callers to ensure that it works correctly.
1 parent 5361a8e commit 1fbac86

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

OnTopic.Editor.AspNetCore/Controllers/EditorController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,12 @@ public async Task<IActionResult> Import(IFormFile jsonFile, [Bind(Prefix = "Impo
649649
\-----------------------------------------------------------------------------------------------------------------------*/
650650
var editorViewModel = await GetEditorViewModel<ImportViewModel>(contentTypeDescriptor, false, false);
651651

652+
options.CurrentUser = HttpContext.User.Identity.Name?? "System";
653+
652654
editorViewModel.ImportOptions = options;
653655

654656
/*------------------------------------------------------------------------------------------------------------------------
655-
| Validate parameters
657+
| VALIDATE PARAMETERS
656658
\-----------------------------------------------------------------------------------------------------------------------*/
657659
if (jsonFile == null) {
658660
ModelState.AddModelError("jsonFile", "The JSON file is required to import data.");

0 commit comments

Comments
 (0)