Set ErrorViewModel in ConfirmEmail (#180)

Addresses #80
This commit is contained in:
Jass Bagga 2017-12-07 12:44:48 -08:00 committed by GitHub
parent 88e05f71a5
commit ed9e34caab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 12 deletions

View File

@ -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]

View File

@ -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);
}
}