React to EF changes and fixed sample
This commit is contained in:
parent
545ca2907f
commit
993827ee65
|
|
@ -10,12 +10,18 @@ using System.Threading.Tasks;
|
||||||
namespace IdentitySample.Models
|
namespace IdentitySample.Models
|
||||||
{
|
{
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class AccountController(UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager)
|
public class AccountController : Controller
|
||||||
: 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
|
// 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
|
// 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);
|
isPersistent: false);
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,17 @@ using System.Threading.Tasks;
|
||||||
namespace IdentitySample
|
namespace IdentitySample
|
||||||
{
|
{
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class ManageController(UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager)
|
public class ManageController : Controller
|
||||||
: 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
|
// GET: /Account/Index
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ using IdentitySample.Models;
|
||||||
|
|
||||||
namespace IdentitySamples
|
namespace IdentitySamples
|
||||||
{
|
{
|
||||||
public static class UseExt {
|
public static class UseExt
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Middleware constructors need to take IOptionsAccessor<TOptions>
|
* 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,
|
* Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources,
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,8 @@
|
||||||
"description": "Identity sample MVC application on K",
|
"description": "Identity sample MVC application on K",
|
||||||
"version": "1.0.0-*",
|
"version": "1.0.0-*",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNet.Http": "1.0.0-*",
|
|
||||||
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
|
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Mvc": "6.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.Server.WebListener": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Diagnostics": "1.0.0-*",
|
"Microsoft.AspNet.Diagnostics": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Identity.SqlServer": "3.0.0-*",
|
"Microsoft.AspNet.Identity.SqlServer": "3.0.0-*",
|
||||||
|
|
|
||||||
|
|
@ -79,17 +79,17 @@ namespace Microsoft.AspNet.Identity.SqlServer
|
||||||
//var urfk2 = userRoleType.GetOrAddForeignKey(roleType.GetPrimaryKey(), new[] { userRoleType.GetProperty("RoleId") });
|
//var urfk2 = userRoleType.GetOrAddForeignKey(roleType.GetPrimaryKey(), new[] { userRoleType.GetProperty("RoleId") });
|
||||||
//roleType.AddNavigation(new Navigation(urfk2, "Users", false));
|
//roleType.AddNavigation(new Navigation(urfk2, "Users", false));
|
||||||
|
|
||||||
var rcfk = roleClaimType.GetOrAddForeignKey(roleType.GetPrimaryKey(), new[] { roleClaimType.GetProperty("RoleId") });
|
var rcfk = roleClaimType.GetOrAddForeignKey(new[] { roleClaimType.GetProperty("RoleId") }, roleType.GetPrimaryKey());
|
||||||
roleType.AddNavigation(new Navigation(rcfk, "Claims", false));
|
roleType.AddNavigation("Claims", rcfk, false);
|
||||||
|
|
||||||
builder.Entity<IdentityUserRole<TKey>>(b =>
|
builder.Entity<IdentityUserRole<TKey>>(b =>
|
||||||
{
|
{
|
||||||
b.Key(r => new { r.UserId, r.RoleId });
|
b.Key(r => new { r.UserId, r.RoleId });
|
||||||
b.ToTable("AspNetUserRoles");
|
b.ToTable("AspNetUserRoles");
|
||||||
});
|
});
|
||||||
// Blocks delete currently without cascade
|
// Blocks delete currently without cascade
|
||||||
//.ForeignKeys(fk => fk.ForeignKey<TUser>(f => f.UserId))
|
//.ForeignKeys(fk => fk.ForeignKey<TUser>(f => f.UserId))
|
||||||
//.ForeignKeys(fk => fk.ForeignKey<TRole>(f => f.RoleId));
|
//.ForeignKeys(fk => fk.ForeignKey<TRole>(f => f.RoleId));
|
||||||
|
|
||||||
builder.Entity<IdentityUserLogin<TKey>>(b =>
|
builder.Entity<IdentityUserLogin<TKey>>(b =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue