diff --git a/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs b/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs index e47d0e69ff..9b12c9cc16 100644 --- a/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs +++ b/DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs @@ -99,13 +99,14 @@ public IActionResult AddSuperviseDelegate(MyStaffListViewModel model) var supervisorEmail = GetUserEmail(); ModelState.Remove("Page"); - if (ModelState.IsValid) + if (ModelState.IsValid && supervisorEmail != model.DelegateEmail) { AddSupervisorDelegateAndReturnId(adminId, model.DelegateEmail ?? String.Empty, supervisorEmail, centreId); return RedirectToAction("MyStaffList", model.Page); } else { + if (supervisorEmail == model.DelegateEmail) { ModelState.AddModelError("DelegateEmail", "The email address must not match the email address you are logged in with."); } ModelState.ClearErrorsForAllFieldsExcept("DelegateEmail"); return MyStaffList(model.SearchString, model.SortBy, model.SortDirection, model.Page); } @@ -131,7 +132,7 @@ public IActionResult AddMultipleSuperviseDelegates(AddMultipleSupervisorDelegate var delegateEmailsList = NewlineSeparatedStringListHelper.SplitNewlineSeparatedList(model.DelegateEmails); foreach (var delegateEmail in delegateEmailsList) { - if (delegateEmail.Length > 0) + if (delegateEmail.Length > 0 && supervisorEmail != delegateEmail) { if (RegexStringValidationHelper.IsValidEmail(delegateEmail)) { diff --git a/DigitalLearningSolutions.Web/Views/Shared/Components/TextInput/Default.cshtml b/DigitalLearningSolutions.Web/Views/Shared/Components/TextInput/Default.cshtml index 7c051ad49f..b8cbf14122 100644 --- a/DigitalLearningSolutions.Web/Views/Shared/Components/TextInput/Default.cshtml +++ b/DigitalLearningSolutions.Web/Views/Shared/Components/TextInput/Default.cshtml @@ -1,7 +1,7 @@ @using DigitalLearningSolutions.Web.ViewModels.Common.ViewComponents @using DigitalLearningSolutions.Web.Helpers @model TextInputViewModel -