React to aspnet/Mvc#3165
This commit is contained in:
parent
a3f24bcb1d
commit
019a50b3db
|
|
@ -146,7 +146,7 @@ namespace MusicStore.Controllers
|
||||||
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
|
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
|
||||||
// Send an email with this link
|
// Send an email with this link
|
||||||
string code = await UserManager.GenerateEmailConfirmationTokenAsync(user);
|
string code = await UserManager.GenerateEmailConfirmationTokenAsync(user);
|
||||||
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Context.Request.Scheme);
|
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
|
||||||
await MessageServices.SendEmailAsync(model.Email, "Confirm your account",
|
await MessageServices.SendEmailAsync(model.Email, "Confirm your account",
|
||||||
"Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
|
"Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
|
||||||
#if !DEMO
|
#if !DEMO
|
||||||
|
|
@ -210,7 +210,7 @@ namespace MusicStore.Controllers
|
||||||
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
|
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
|
||||||
// Send an email with this link
|
// Send an email with this link
|
||||||
string code = await UserManager.GeneratePasswordResetTokenAsync(user);
|
string code = await UserManager.GeneratePasswordResetTokenAsync(user);
|
||||||
var callbackUrl = Url.Action("ResetPassword", "Account", new { code = code }, protocol: Context.Request.Scheme);
|
var callbackUrl = Url.Action("ResetPassword", "Account", new { code = code }, protocol: HttpContext.Request.Scheme);
|
||||||
await MessageServices.SendEmailAsync(model.Email, "Reset Password",
|
await MessageServices.SendEmailAsync(model.Email, "Reset Password",
|
||||||
"Please reset your password by clicking here: <a href=\"" + callbackUrl + "\">link</a>");
|
"Please reset your password by clicking here: <a href=\"" + callbackUrl + "\">link</a>");
|
||||||
#if !DEMO
|
#if !DEMO
|
||||||
|
|
@ -438,16 +438,16 @@ namespace MusicStore.Controllers
|
||||||
public async Task<ActionResult> LogOff()
|
public async Task<ActionResult> LogOff()
|
||||||
{
|
{
|
||||||
// clear all items from the cart
|
// clear all items from the cart
|
||||||
Context.Session.Clear();
|
HttpContext.Session.Clear();
|
||||||
|
|
||||||
await SignInManager.SignOutAsync();
|
await SignInManager.SignOutAsync();
|
||||||
|
|
||||||
// TODO: Currently SignInManager.SignOut does not sign out OpenIdc and does not have a way to pass in a specific
|
// TODO: Currently SignInManager.SignOut does not sign out OpenIdc and does not have a way to pass in a specific
|
||||||
// AuthType to sign out.
|
// AuthType to sign out.
|
||||||
var appEnv = Context.RequestServices.GetService<IHostingEnvironment>();
|
var appEnv = HttpContext.RequestServices.GetService<IHostingEnvironment>();
|
||||||
if (appEnv.EnvironmentName.StartsWith("OpenIdConnect"))
|
if (appEnv.EnvironmentName.StartsWith("OpenIdConnect"))
|
||||||
{
|
{
|
||||||
await Context.Authentication.SignOutAsync("OpenIdConnect");
|
await HttpContext.Authentication.SignOutAsync("OpenIdConnect");
|
||||||
}
|
}
|
||||||
|
|
||||||
return RedirectToAction("Index", "Home");
|
return RedirectToAction("Index", "Home");
|
||||||
|
|
@ -473,7 +473,7 @@ namespace MusicStore.Controllers
|
||||||
|
|
||||||
private async Task<ApplicationUser> GetCurrentUserAsync()
|
private async Task<ApplicationUser> GetCurrentUserAsync()
|
||||||
{
|
{
|
||||||
return await UserManager.FindByIdAsync(Context.User.GetUserId());
|
return await UserManager.FindByIdAsync(HttpContext.User.GetUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionResult RedirectToLocal(string returnUrl)
|
private ActionResult RedirectToLocal(string returnUrl)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace MusicStore.Controllers
|
||||||
return View(order);
|
return View(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
var formCollection = await Context.Request.ReadFormAsync();
|
var formCollection = await HttpContext.Request.ReadFormAsync();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -48,14 +48,14 @@ namespace MusicStore.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
order.Username = Context.User.GetUserName();
|
order.Username = HttpContext.User.GetUserName();
|
||||||
order.OrderDate = DateTime.Now;
|
order.OrderDate = DateTime.Now;
|
||||||
|
|
||||||
//Add the Order
|
//Add the Order
|
||||||
DbContext.Orders.Add(order);
|
DbContext.Orders.Add(order);
|
||||||
|
|
||||||
//Process the order
|
//Process the order
|
||||||
var cart = ShoppingCart.GetCart(DbContext, Context);
|
var cart = ShoppingCart.GetCart(DbContext, HttpContext);
|
||||||
await cart.CreateOrder(order);
|
await cart.CreateOrder(order);
|
||||||
|
|
||||||
// Save all changes
|
// Save all changes
|
||||||
|
|
@ -79,7 +79,7 @@ namespace MusicStore.Controllers
|
||||||
// Validate customer owns this order
|
// Validate customer owns this order
|
||||||
bool isValid = await DbContext.Orders.AnyAsync(
|
bool isValid = await DbContext.Orders.AnyAsync(
|
||||||
o => o.OrderId == id &&
|
o => o.OrderId == id &&
|
||||||
o.Username == Context.User.GetUserName());
|
o.Username == HttpContext.User.GetUserName());
|
||||||
|
|
||||||
if (isValid)
|
if (isValid)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,7 @@ namespace MusicStore.Controllers
|
||||||
|
|
||||||
private async Task<ApplicationUser> GetCurrentUserAsync()
|
private async Task<ApplicationUser> GetCurrentUserAsync()
|
||||||
{
|
{
|
||||||
return await UserManager.FindByIdAsync(Context.User.GetUserId());
|
return await UserManager.FindByIdAsync(HttpContext.User.GetUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace MusicStore.Controllers
|
||||||
// GET: /ShoppingCart/
|
// GET: /ShoppingCart/
|
||||||
public async Task<IActionResult> Index()
|
public async Task<IActionResult> Index()
|
||||||
{
|
{
|
||||||
var cart = ShoppingCart.GetCart(DbContext, Context);
|
var cart = ShoppingCart.GetCart(DbContext, HttpContext);
|
||||||
|
|
||||||
// Set up our ViewModel
|
// Set up our ViewModel
|
||||||
var viewModel = new ShoppingCartViewModel
|
var viewModel = new ShoppingCartViewModel
|
||||||
|
|
@ -45,7 +45,7 @@ namespace MusicStore.Controllers
|
||||||
.Single(album => album.AlbumId == id);
|
.Single(album => album.AlbumId == id);
|
||||||
|
|
||||||
// Add it to the shopping cart
|
// Add it to the shopping cart
|
||||||
var cart = ShoppingCart.GetCart(DbContext, Context);
|
var cart = ShoppingCart.GetCart(DbContext, HttpContext);
|
||||||
|
|
||||||
cart.AddToCart(addedAlbum);
|
cart.AddToCart(addedAlbum);
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ namespace MusicStore.Controllers
|
||||||
StringValues tokenHeaders;
|
StringValues tokenHeaders;
|
||||||
string[] tokens = null;
|
string[] tokens = null;
|
||||||
|
|
||||||
if (Context.Request.Headers.TryGetValue("RequestVerificationToken", out tokenHeaders))
|
if (HttpContext.Request.Headers.TryGetValue("RequestVerificationToken", out tokenHeaders))
|
||||||
{
|
{
|
||||||
tokens = tokenHeaders.First().Split(':');
|
tokens = tokenHeaders.First().Split(':');
|
||||||
if (tokens != null && tokens.Length == 2)
|
if (tokens != null && tokens.Length == 2)
|
||||||
|
|
@ -75,10 +75,10 @@ namespace MusicStore.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Antiforgery.ValidateTokens(Context, new AntiforgeryTokenSet(formToken, cookieToken));
|
Antiforgery.ValidateTokens(HttpContext, new AntiforgeryTokenSet(formToken, cookieToken));
|
||||||
|
|
||||||
// Retrieve the current user's shopping cart
|
// Retrieve the current user's shopping cart
|
||||||
var cart = ShoppingCart.GetCart(DbContext, Context);
|
var cart = ShoppingCart.GetCart(DbContext, HttpContext);
|
||||||
|
|
||||||
// Get the name of the album to display confirmation
|
// Get the name of the album to display confirmation
|
||||||
var cartItem = await DbContext.CartItems
|
var cartItem = await DbContext.CartItems
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue