From 5d661a87c8c7bff9501f09a6864bcf12f34a96da Mon Sep 17 00:00:00 2001 From: MrKevJoy <60096576+MrKevJoy@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:40:44 +0000 Subject: [PATCH] Fix selected trn from being lost when merging two records (#780) --- .../Pages/Admin/MergeUser/Confirm.cshtml | 6 +++--- .../Pages/Admin/MergeUser/Confirm.cshtml.cs | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/MergeUser/Confirm.cshtml b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/MergeUser/Confirm.cshtml index 274f9364e..0840c9cb0 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/MergeUser/Confirm.cshtml +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/MergeUser/Confirm.cshtml @@ -5,14 +5,14 @@ } @section BeforeContent { - + }

@ViewBag.Title

- + @Html.Hidden("ChosenTrn", Model.ChosenTrn) Email address @@ -20,7 +20,7 @@ Name - @Model.User!.FirstName @Model.User!.LastName + @Model.User!.FirstName @Model.User!.LastName TRN diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/MergeUser/Confirm.cshtml.cs b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/MergeUser/Confirm.cshtml.cs index 202a95eb9..1effd5473 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/MergeUser/Confirm.cshtml.cs +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Admin/MergeUser/Confirm.cshtml.cs @@ -29,9 +29,10 @@ public Confirm(TeacherIdentityServerDbContext dbContext, IClock clock) public User? UserToMerge { get; set; } - [FromQuery(Name = "trn")] + [BindProperty] public string? ChosenTrn { get; set; } + public void OnGet() { } @@ -121,6 +122,11 @@ private void UpdateMergedUser(User user) private bool ValidateChosenTrn() { + if (Request.Query.ContainsKey("trn")) + { + ChosenTrn = Request.Query["trn"]; + } + ChosenTrn = ChosenTrn == "None" ? null : ChosenTrn ?? User!.Trn; return ChosenTrn == User!.Trn || ChosenTrn == UserToMerge!.Trn; }