Bye Bye Primary Ctors :(
This commit is contained in:
parent
bd7ae6d8c0
commit
545ca2907f
|
|
@ -12,34 +12,39 @@ using Microsoft.Data.Entity;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Identity.SqlServer
|
namespace Microsoft.AspNet.Identity.SqlServer
|
||||||
{
|
{
|
||||||
public class RoleStore<TRole>(DbContext context) : RoleStore<TRole, DbContext, string>(context)
|
public class RoleStore<TRole> : RoleStore<TRole, DbContext, string>
|
||||||
where TRole : IdentityRole
|
where TRole : IdentityRole
|
||||||
{ }
|
{
|
||||||
|
public RoleStore(DbContext context) : base(context) { }
|
||||||
|
}
|
||||||
|
|
||||||
public class RoleStore<TRole, TContext>(TContext context) : RoleStore<TRole, TContext, string>(context)
|
public class RoleStore<TRole, TContext> : RoleStore<TRole, TContext, string>
|
||||||
where TRole : IdentityRole
|
where TRole : IdentityRole
|
||||||
where TContext : DbContext
|
where TContext : DbContext
|
||||||
{ }
|
{
|
||||||
|
public RoleStore(TContext context) : base(context) { }
|
||||||
|
}
|
||||||
|
|
||||||
public class RoleStore<TRole, TContext, TKey>(TContext context) :
|
public class RoleStore<TRole, TContext, TKey> :
|
||||||
IQueryableRoleStore<TRole>,
|
IQueryableRoleStore<TRole>,
|
||||||
IRoleClaimStore<TRole>
|
IRoleClaimStore<TRole>
|
||||||
where TRole : IdentityRole<TKey>
|
where TRole : IdentityRole<TKey>
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
where TContext : DbContext
|
where TContext : DbContext
|
||||||
{
|
{
|
||||||
// Primary constructor
|
public RoleStore(TContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("context");
|
throw new ArgumentNullException("context");
|
||||||
}
|
}
|
||||||
|
Context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
|
|
||||||
public TContext Context { get; } = context;
|
public TContext Context { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true will call SaveChanges after CreateAsync/UpdateAsync/DeleteAsync
|
/// If true will call SaveChanges after CreateAsync/UpdateAsync/DeleteAsync
|
||||||
|
|
|
||||||
|
|
@ -13,20 +13,26 @@ using Microsoft.Data.Entity;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Identity.SqlServer
|
namespace Microsoft.AspNet.Identity.SqlServer
|
||||||
{
|
{
|
||||||
public class UserStore(DbContext context) : UserStore<IdentityUser>(context)
|
public class UserStore : UserStore<IdentityUser>
|
||||||
{ }
|
{
|
||||||
|
public UserStore(DbContext context) : base(context) { }
|
||||||
|
}
|
||||||
|
|
||||||
public class UserStore<TUser>(DbContext context) : UserStore<TUser, IdentityRole, DbContext>(context)
|
public class UserStore<TUser> : UserStore<TUser, IdentityRole, DbContext>
|
||||||
where TUser : IdentityUser, new()
|
where TUser : IdentityUser, new()
|
||||||
{ }
|
{
|
||||||
|
public UserStore(DbContext context) : base(context) { }
|
||||||
|
}
|
||||||
|
|
||||||
public class UserStore<TUser, TRole, TContext>(TContext context) : UserStore<TUser, TRole, TContext, string>(context)
|
public class UserStore<TUser, TRole, TContext> : UserStore<TUser, TRole, TContext, string>
|
||||||
where TUser : IdentityUser, new()
|
where TUser : IdentityUser, new()
|
||||||
where TRole : IdentityRole, new()
|
where TRole : IdentityRole, new()
|
||||||
where TContext : DbContext
|
where TContext : DbContext
|
||||||
{ }
|
{
|
||||||
|
public UserStore(TContext context) : base(context) { }
|
||||||
|
}
|
||||||
|
|
||||||
public class UserStore<TUser, TRole, TContext, TKey>(TContext context) :
|
public class UserStore<TUser, TRole, TContext, TKey> :
|
||||||
IUserLoginStore<TUser>,
|
IUserLoginStore<TUser>,
|
||||||
IUserRoleStore<TUser>,
|
IUserRoleStore<TUser>,
|
||||||
IUserClaimStore<TUser>,
|
IUserClaimStore<TUser>,
|
||||||
|
|
@ -42,17 +48,19 @@ namespace Microsoft.AspNet.Identity.SqlServer
|
||||||
where TContext : DbContext
|
where TContext : DbContext
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
// Primary constructor
|
|
||||||
|
public UserStore(TContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("context");
|
throw new ArgumentNullException("context");
|
||||||
}
|
}
|
||||||
|
Context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public TContext Context { get; } = context;
|
public TContext Context { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true will call SaveChanges after CreateAsync/UpdateAsync/DeleteAsync
|
/// If true will call SaveChanges after CreateAsync/UpdateAsync/DeleteAsync
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,9 @@ namespace Microsoft.AspNet.Identity
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Token provider that uses an IDataProtector to generate encrypted tokens based off of the security stamp
|
/// Token provider that uses an IDataProtector to generate encrypted tokens based off of the security stamp
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DataProtectorTokenProvider<TUser>(DataProtectionTokenProviderOptions options, IDataProtector protector) : IUserTokenProvider<TUser> where TUser : class
|
public class DataProtectorTokenProvider<TUser> : IUserTokenProvider<TUser> where TUser : class
|
||||||
{
|
{
|
||||||
|
public DataProtectorTokenProvider(DataProtectionTokenProviderOptions options, IDataProtector protector)
|
||||||
{
|
{
|
||||||
if (options == null)
|
if (options == null)
|
||||||
{
|
{
|
||||||
|
|
@ -28,10 +29,12 @@ namespace Microsoft.AspNet.Identity
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(protector));
|
throw new ArgumentNullException(nameof(protector));
|
||||||
}
|
}
|
||||||
|
Options = options;
|
||||||
|
Protector = protector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataProtectionTokenProviderOptions Options { get; } = options;
|
public DataProtectionTokenProviderOptions Options { get; private set; }
|
||||||
public IDataProtector Protector { get; } = protector;
|
public IDataProtector Protector { get; private set; }
|
||||||
|
|
||||||
public string Name { get { return Options.Name; } }
|
public string Name { get { return Options.Name; } }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,18 @@ namespace Microsoft.AspNet.Identity
|
||||||
/// TokenProvider that generates tokens from the user's security stamp and notifies a user via their email
|
/// TokenProvider that generates tokens from the user's security stamp and notifies a user via their email
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TUser"></typeparam>
|
/// <typeparam name="TUser"></typeparam>
|
||||||
public class EmailTokenProvider<TUser>(EmailTokenProviderOptions options) : TotpSecurityStampBasedTokenProvider<TUser>
|
public class EmailTokenProvider<TUser> : TotpSecurityStampBasedTokenProvider<TUser>
|
||||||
where TUser : class
|
where TUser : class
|
||||||
{
|
{
|
||||||
|
public EmailTokenProvider(EmailTokenProviderOptions options)
|
||||||
|
{
|
||||||
|
Options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public EmailTokenProvider() : this(new EmailTokenProviderOptions()) { }
|
public EmailTokenProvider() : this(new EmailTokenProviderOptions()) { }
|
||||||
|
|
||||||
public EmailTokenProviderOptions Options { get; } = options;
|
public EmailTokenProviderOptions Options { get; private set; }
|
||||||
|
|
||||||
public override string Name { get { return Options.Name; } }
|
public override string Name { get { return Options.Name; } }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,14 @@ using System.Security.Claims;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Identity
|
namespace Microsoft.AspNet.Identity
|
||||||
{
|
{
|
||||||
public class ExternalLoginInfo(ClaimsIdentity externalIdentity, string loginProvider, string providerKey,
|
public class ExternalLoginInfo : UserLoginInfo
|
||||||
string displayName) : UserLoginInfo(loginProvider, providerKey, displayName)
|
|
||||||
{
|
{
|
||||||
public ClaimsIdentity ExternalIdentity { get; set; } = externalIdentity;
|
public ExternalLoginInfo(ClaimsIdentity externalIdentity, string loginProvider, string providerKey,
|
||||||
|
string displayName) : base(loginProvider, providerKey, displayName)
|
||||||
|
{
|
||||||
|
ExternalIdentity = externalIdentity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClaimsIdentity ExternalIdentity { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -33,8 +33,10 @@ namespace Microsoft.AspNet.Identity
|
||||||
/// Represents a Role entity
|
/// Represents a Role entity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TKey"></typeparam>
|
/// <typeparam name="TKey"></typeparam>
|
||||||
public class IdentityRole<TKey>() where TKey : IEquatable<TKey>
|
public class IdentityRole<TKey> where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
|
public IdentityRole() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,10 @@ namespace Microsoft.AspNet.Identity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class IdentityUser<TKey>() where TKey : IEquatable<TKey>
|
public class IdentityUser<TKey> where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
|
public IdentityUser() { }
|
||||||
|
|
||||||
public IdentityUser(string userName) : this()
|
public IdentityUser(string userName) : this()
|
||||||
{
|
{
|
||||||
UserName = userName;
|
UserName = userName;
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,18 @@ namespace Microsoft.AspNet.Identity
|
||||||
/// TokenProvider that generates tokens from the user's security stamp and notifies a user via their phone number
|
/// TokenProvider that generates tokens from the user's security stamp and notifies a user via their phone number
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TUser"></typeparam>
|
/// <typeparam name="TUser"></typeparam>
|
||||||
public class PhoneNumberTokenProvider<TUser>(PhoneNumberTokenProviderOptions options) : TotpSecurityStampBasedTokenProvider<TUser>
|
public class PhoneNumberTokenProvider<TUser> : TotpSecurityStampBasedTokenProvider<TUser>
|
||||||
where TUser : class
|
where TUser : class
|
||||||
{
|
{
|
||||||
|
public PhoneNumberTokenProvider(PhoneNumberTokenProviderOptions options)
|
||||||
|
{
|
||||||
|
Options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public PhoneNumberTokenProvider() : this(new PhoneNumberTokenProviderOptions()) { }
|
public PhoneNumberTokenProvider() : this(new PhoneNumberTokenProviderOptions()) { }
|
||||||
|
|
||||||
public PhoneNumberTokenProviderOptions Options { get; } = options;
|
public PhoneNumberTokenProviderOptions Options { get; private set; }
|
||||||
|
|
||||||
public override string Name { get { return Options.Name; } }
|
public override string Name { get { return Options.Name; } }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,28 @@ namespace Microsoft.AspNet.Identity
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a linked login for a user (i.e. a local username/password or a facebook/google account
|
/// Represents a linked login for a user (i.e. a local username/password or a facebook/google account
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UserLoginInfo(string loginProvider, string providerKey, string displayName)
|
public class UserLoginInfo
|
||||||
{
|
{
|
||||||
|
public UserLoginInfo(string loginProvider, string providerKey, string displayName)
|
||||||
|
{
|
||||||
|
LoginProvider = loginProvider;
|
||||||
|
ProviderKey = providerKey;
|
||||||
|
ProviderDisplayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provider for the linked login, i.e. Local, Facebook, Google, etc.
|
/// Provider for the linked login, i.e. Local, Facebook, Google, etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string LoginProvider { get; set; } = loginProvider;
|
public string LoginProvider { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Key for the linked login at the provider
|
/// Key for the linked login at the provider
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ProviderKey { get; set; } = providerKey;
|
public string ProviderKey { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Display name for the provider
|
/// Display name for the provider
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ProviderDisplayName { get; set; } = displayName;
|
public string ProviderDisplayName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue