External Login
This commit is contained in:
parent
1ee4e5035c
commit
0cfc1dc95a
2 changed files with 10 additions and 6 deletions
|
|
@ -35,8 +35,6 @@ namespace Yavsc.Models
|
|||
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Yavsc.Abstract.Models.Messaging;
|
||||
using Org.BouncyCastle.Asn1.Crmf;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
|
||||
{
|
||||
|
|
@ -44,10 +42,12 @@ namespace Yavsc.Models
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
|
@ -86,7 +86,7 @@ namespace Yavsc.Models
|
|||
}
|
||||
|
||||
builder.Entity<Activity>().Property(a => a.ParentCode).IsRequired(false);
|
||||
builder.Entity<IdentityUserLogin<String>>().HasKey(i=> new { i.LoginProvider, i.UserId, i.ProviderKey });
|
||||
// builder.Entity<IdentityUserLogin<String>>().HasKey(i=> new { i.LoginProvider, i.UserId, i.ProviderKey });
|
||||
}
|
||||
|
||||
// this is not a failback procedure.
|
||||
|
|
@ -301,6 +301,6 @@ namespace Yavsc.Models
|
|||
public DbSet<Scope> Scopes { get; set; }
|
||||
|
||||
public DbSet<BlogSpotPublication> blogSpotPublications{ get; set; }
|
||||
public DbSet<IdentityUserLogin<String>> AspNetUserLogins { get; set; }
|
||||
// public DbSet<IdentityUserLogin<String>> AspNetUserLogins { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Interfaces;
|
||||
using Yavsc.Models;
|
||||
|
|
@ -6,10 +7,12 @@ using Yavsc.Models;
|
|||
public class ExternalIdentityManager : IExternalIdentityManager
|
||||
{
|
||||
private ApplicationDbContext _applicationDbContext;
|
||||
private SignInManager<ApplicationUser> _signInManager;
|
||||
|
||||
public ExternalIdentityManager(ApplicationDbContext applicationDbContext)
|
||||
public ExternalIdentityManager(ApplicationDbContext applicationDbContext, SignInManager<ApplicationUser> signInManager)
|
||||
{
|
||||
_applicationDbContext = applicationDbContext;
|
||||
_signInManager = signInManager;
|
||||
}
|
||||
public ApplicationUser AutoProvisionUser(string provider, string providerUserId, List<Claim> claims)
|
||||
{
|
||||
|
|
@ -18,7 +21,8 @@ public class ExternalIdentityManager : IExternalIdentityManager
|
|||
|
||||
public async Task<ApplicationUser?> FindByExternaleProviderAsync(string provider, string providerUserId)
|
||||
{
|
||||
var user = await _applicationDbContext.AspNetUserLogins
|
||||
|
||||
var user = await _applicationDbContext.UserLogins
|
||||
.FirstOrDefaultAsync(
|
||||
i => (i.LoginProvider == provider) && (i.ProviderKey == providerUserId)
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue