React to EF changes and fixed sample

This commit is contained in:
David Fowler 2014-10-05 02:55:14 -07:00
parent 545ca2907f
commit 993827ee65
5 changed files with 29 additions and 21 deletions

View File

@ -10,12 +10,18 @@ using System.Threading.Tasks;
namespace IdentitySample.Models
{
[Authorize]
public class AccountController(UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager)
: Controller
public class AccountController : Controller
{
public UserManager<ApplicationUser> UserManager { get; } = userManager;
public AccountController(UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager)
{
UserManager = UserManager;
SignInManager = signInManager;
}
public UserManager<ApplicationUser> UserManager { get; private set; }
public SignInManager<ApplicationUser> SignInManager { get; private set; }
public SignInManager<ApplicationUser> SignInManager { get; } = signInManager;
//
// GET: /Account/Login
@ -129,7 +135,7 @@ namespace IdentitySample.Models
}
// Sign in the user with this external login provider if the user already has a login
var result = await SignInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey,
var result = await SignInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey,
isPersistent: false);
switch (result)
{

View File

@ -9,12 +9,17 @@ using System.Threading.Tasks;
namespace IdentitySample
{
[Authorize]
public class ManageController(UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager)
: Controller
public class ManageController : Controller
{
public UserManager<ApplicationUser> UserManager { get; } = userManager;
public ManageController(UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager)
{
UserManager = UserManager;
SignInManager = signInManager;
}
public SignInManager<ApplicationUser> SignInManager { get; } = signInManager;
public UserManager<ApplicationUser> UserManager { get; private set; }
public SignInManager<ApplicationUser> SignInManager { get; private set; }
//
// GET: /Account/Index

View File

@ -15,7 +15,8 @@ using IdentitySample.Models;
namespace IdentitySamples
{
public static class UseExt {
public static class UseExt
{
/**
* TODO: Middleware constructors need to take IOptionsAccessor<TOptions>
@ -73,8 +74,9 @@ namespace IdentitySamples
}
}
public partial class Startup()
public partial class Startup
{
public Startup()
{
/*
* Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources,

View File

@ -5,13 +5,8 @@
"description": "Identity sample MVC application on K",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Core": "6.0.0-*",
"Microsoft.AspNet.Mvc.ModelBinding": "6.0.0-*",
"Microsoft.AspNet.Mvc.Razor": "6.0.0-*",
"Microsoft.AspNet.Routing": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.AspNet.Diagnostics": "1.0.0-*",
"Microsoft.AspNet.Identity.SqlServer": "3.0.0-*",

View File

@ -79,17 +79,17 @@ namespace Microsoft.AspNet.Identity.SqlServer
//var urfk2 = userRoleType.GetOrAddForeignKey(roleType.GetPrimaryKey(), new[] { userRoleType.GetProperty("RoleId") });
//roleType.AddNavigation(new Navigation(urfk2, "Users", false));
var rcfk = roleClaimType.GetOrAddForeignKey(roleType.GetPrimaryKey(), new[] { roleClaimType.GetProperty("RoleId") });
roleType.AddNavigation(new Navigation(rcfk, "Claims", false));
var rcfk = roleClaimType.GetOrAddForeignKey(new[] { roleClaimType.GetProperty("RoleId") }, roleType.GetPrimaryKey());
roleType.AddNavigation("Claims", rcfk, false);
builder.Entity<IdentityUserRole<TKey>>(b =>
{
b.Key(r => new { r.UserId, r.RoleId });
b.ToTable("AspNetUserRoles");
});
// Blocks delete currently without cascade
//.ForeignKeys(fk => fk.ForeignKey<TUser>(f => f.UserId))
//.ForeignKeys(fk => fk.ForeignKey<TRole>(f => f.RoleId));
// Blocks delete currently without cascade
//.ForeignKeys(fk => fk.ForeignKey<TUser>(f => f.UserId))
//.ForeignKeys(fk => fk.ForeignKey<TRole>(f => f.RoleId));
builder.Entity<IdentityUserLogin<TKey>>(b =>
{