Skip to content

Commit ed9e34c

Browse files
authored
Set ErrorViewModel in ConfirmEmail (#180)
Addresses #80
1 parent 88e05f7 commit ed9e34c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Areas/Identity/Controllers/AccountController.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.Linq;
45
using System.Security.Claims;
56
using System.Text.Encodings.Web;
@@ -15,6 +16,7 @@
1516
using Company.WebApplication1.Identity.Models;
1617
using Company.WebApplication1.Identity.Models.AccountViewModels;
1718
using Company.WebApplication1.Identity.Services;
19+
using Company.WebApplication1.Models;
1820

1921
namespace Company.WebApplication1.Identity.Controllers
2022
{
@@ -346,7 +348,14 @@ public async Task<IActionResult> ConfirmEmail(string userId, string code)
346348
throw new ApplicationException($"Unable to load user with ID '{userId}'.");
347349
}
348350
var result = await _userManager.ConfirmEmailAsync(user, code);
349-
return View(result.Succeeded ? "ConfirmEmail" : "Error");
351+
if (result.Succeeded)
352+
{
353+
return View("ConfirmEmail");
354+
}
355+
else
356+
{
357+
return View("Error", new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
358+
}
350359
}
351360

352361
[HttpGet]

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Areas/Identity/Models/ErrorViewModel.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)