From ed9e34caab043e1ff73ec445969f3e8156d2a508 Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Thu, 7 Dec 2017 12:44:48 -0800 Subject: [PATCH] Set ErrorViewModel in ConfirmEmail (#180) Addresses #80 --- .../Areas/Identity/Controllers/AccountController.cs | 11 ++++++++++- .../Areas/Identity/Models/ErrorViewModel.cs | 11 ----------- 2 files changed, 10 insertions(+), 12 deletions(-) delete mode 100644 src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Areas/Identity/Models/ErrorViewModel.cs diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Areas/Identity/Controllers/AccountController.cs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Areas/Identity/Controllers/AccountController.cs index 043acc240e..aab6086c94 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Areas/Identity/Controllers/AccountController.cs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Areas/Identity/Controllers/AccountController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Security.Claims; using System.Text.Encodings.Web; @@ -15,6 +16,7 @@ using Company.WebApplication1.Controllers; using Company.WebApplication1.Identity.Models; using Company.WebApplication1.Identity.Models.AccountViewModels; using Company.WebApplication1.Identity.Services; +using Company.WebApplication1.Models; namespace Company.WebApplication1.Identity.Controllers { @@ -346,7 +348,14 @@ namespace Company.WebApplication1.Identity.Controllers throw new ApplicationException($"Unable to load user with ID '{userId}'."); } var result = await _userManager.ConfirmEmailAsync(user, code); - return View(result.Succeeded ? "ConfirmEmail" : "Error"); + if (result.Succeeded) + { + return View("ConfirmEmail"); + } + else + { + return View("Error", new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + } } [HttpGet] diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Areas/Identity/Models/ErrorViewModel.cs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Areas/Identity/Models/ErrorViewModel.cs deleted file mode 100644 index cd1832cadc..0000000000 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Areas/Identity/Models/ErrorViewModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace Company.WebApplication1.Identity.Models -{ - public class ErrorViewModel - { - public string RequestId { get; set; } - - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - } -} \ No newline at end of file