1. Enabling code to use the [Authorize] filter
2. Marked a few places with bug#s with work arounds 3. Making the app run on CoreCLR by default again (which I reverted by mistake in a previous submit).
This commit is contained in:
parent
9d25c0b1f1
commit
23fb4d8e7d
|
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MusicStore.Controllers
|
namespace MusicStore.Controllers
|
||||||
{
|
{
|
||||||
|
//https://github.com/aspnet/WebFx/issues/309
|
||||||
//[Authorize]
|
//[Authorize]
|
||||||
public class AccountController : Controller
|
public class AccountController : Controller
|
||||||
{
|
{
|
||||||
|
|
@ -18,7 +19,8 @@ namespace MusicStore.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
private SignInManager<ApplicationUser> _signInManager;
|
private SignInManager<ApplicationUser> _signInManager;
|
||||||
public SignInManager<ApplicationUser> SignInManager {
|
public SignInManager<ApplicationUser> SignInManager
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_signInManager == null)
|
if (_signInManager == null)
|
||||||
|
|
@ -32,7 +34,7 @@ namespace MusicStore.Controllers
|
||||||
}
|
}
|
||||||
return _signInManager;
|
return _signInManager;
|
||||||
}
|
}
|
||||||
set { _signInManager = value; }
|
set { _signInManager = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -147,7 +149,7 @@ namespace MusicStore.Controllers
|
||||||
AddErrors(result);
|
AddErrors(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we got this far, something failed, redisplay form
|
// If we got this far, something failed, redisplay form
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
@ -188,7 +190,7 @@ namespace MusicStore.Controllers
|
||||||
//Bug: https://github.com/aspnet/WebFx/issues/244
|
//Bug: https://github.com/aspnet/WebFx/issues/244
|
||||||
returnUrl = string.IsNullOrWhiteSpace(returnUrl) ? "/Home" : returnUrl;
|
returnUrl = string.IsNullOrWhiteSpace(returnUrl) ? "/Home" : returnUrl;
|
||||||
//if (Url.IsLocalUrl(returnUrl))
|
//if (Url.IsLocalUrl(returnUrl))
|
||||||
if(true)
|
if (true)
|
||||||
{
|
{
|
||||||
return Redirect(returnUrl);
|
return Redirect(returnUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MusicStore.Controllers
|
namespace MusicStore.Controllers
|
||||||
{
|
{
|
||||||
//Bug: Missing auth filter
|
[Authorize]
|
||||||
//[Authorize]
|
|
||||||
public class CheckoutController : Controller
|
public class CheckoutController : Controller
|
||||||
{
|
{
|
||||||
private readonly MusicStoreContext db;
|
private readonly MusicStoreContext db;
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,9 @@ using System.Linq;
|
||||||
|
|
||||||
namespace MusicStore.Controllers
|
namespace MusicStore.Controllers
|
||||||
{
|
{
|
||||||
///Bug: No Authorize attribute
|
//https://github.com/aspnet/WebFx/issues/314
|
||||||
//[Authorize(Roles="Administrator")]
|
//[Authorize("ManageStore", "Allowed")]
|
||||||
|
[Authorize]
|
||||||
public class StoreManagerController : Controller
|
public class StoreManagerController : Controller
|
||||||
{
|
{
|
||||||
private readonly MusicStoreContext db;
|
private readonly MusicStoreContext db;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ using MusicStore.Web.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
|
|
@ -113,6 +114,7 @@ public class Startup
|
||||||
user = new ApplicationUser { UserName = userName };
|
user = new ApplicationUser { UserName = userName };
|
||||||
await userManager.CreateAsync(user, password);
|
await userManager.CreateAsync(user, password);
|
||||||
await userManager.AddToRoleAsync(user, adminRole);
|
await userManager.AddToRoleAsync(user, adminRole);
|
||||||
|
await userManager.AddClaimAsync(user, new Claim("ManageStore", "Allowed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<!-- Change below value to 'false' to run on full desktop -->
|
<!-- Change below value to 'false' to run on full desktop -->
|
||||||
<add key="K" value="false" />
|
<add key="K" value="true" />
|
||||||
|
|
||||||
<!-- This will turn on detailed errors when deployed to remote servers -->
|
<!-- This will turn on detailed errors when deployed to remote servers -->
|
||||||
<!-- This setting is not recommended for production -->
|
<!-- This setting is not recommended for production -->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue