added user confirmation extension method (#14409)
This commit is contained in:
parent
654140736c
commit
af9f99299c
|
|
@ -57,6 +57,7 @@ namespace Microsoft.AspNetCore.Identity
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddRoleValidator<TRole>() where TRole : class { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddRoleValidator<TRole>() where TRole : class { throw null; }
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddTokenProvider(string providerName, System.Type provider) { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddTokenProvider(string providerName, System.Type provider) { throw null; }
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddTokenProvider<TProvider>(string providerName) where TProvider : class { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddTokenProvider<TProvider>(string providerName) where TProvider : class { throw null; }
|
||||||
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserConfirmation<TUserConfirmation>() where TUserConfirmation : class { throw null; }
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserManager<TUserManager>() where TUserManager : class { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserManager<TUserManager>() where TUserManager : class { throw null; }
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserStore<TStore>() where TStore : class { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserStore<TStore>() where TStore : class { throw null; }
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserValidator<TValidator>() where TValidator : class { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserValidator<TValidator>() where TValidator : class { throw null; }
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ namespace Microsoft.AspNetCore.Identity
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddRoleValidator<TRole>() where TRole : class { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddRoleValidator<TRole>() where TRole : class { throw null; }
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddTokenProvider(string providerName, System.Type provider) { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddTokenProvider(string providerName, System.Type provider) { throw null; }
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddTokenProvider<TProvider>(string providerName) where TProvider : class { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddTokenProvider<TProvider>(string providerName) where TProvider : class { throw null; }
|
||||||
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserConfirmation<TUserConfirmation>() where TUserConfirmation : class { throw null; }
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserManager<TUserManager>() where TUserManager : class { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserManager<TUserManager>() where TUserManager : class { throw null; }
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserStore<TStore>() where TStore : class { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserStore<TStore>() where TStore : class { throw null; }
|
||||||
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserValidator<TValidator>() where TValidator : class { throw null; }
|
public virtual Microsoft.AspNetCore.Identity.IdentityBuilder AddUserValidator<TValidator>() where TValidator : class { throw null; }
|
||||||
|
|
|
||||||
|
|
@ -238,5 +238,13 @@ namespace Microsoft.AspNetCore.Identity
|
||||||
}
|
}
|
||||||
return AddScoped(managerType, typeof(TRoleManager));
|
return AddScoped(managerType, typeof(TRoleManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a <see cref="IUserConfirmation{TUser}"/> for the <seealso cref="UserType"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TUserConfirmation">The type of the user confirmation to add.</typeparam>
|
||||||
|
/// <returns>The current <see cref="IdentityBuilder"/> instance.</returns>
|
||||||
|
public virtual IdentityBuilder AddUserConfirmation<TUserConfirmation>() where TUserConfirmation : class
|
||||||
|
=> AddScoped(typeof(IUserConfirmation<>).MakeGenericType(UserType), typeof(TUserConfirmation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,22 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||||
Assert.NotNull(thingy);
|
Assert.NotNull(thingy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CanOverrideUserConfirmation()
|
||||||
|
{
|
||||||
|
var services = new ServiceCollection()
|
||||||
|
.AddLogging()
|
||||||
|
.AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
|
||||||
|
services.AddIdentity<PocoUser, PocoRole>()
|
||||||
|
.AddClaimsPrincipalFactory<MyClaimsPrincipalFactory>()
|
||||||
|
.AddUserConfirmation<MyUserConfirmation>()
|
||||||
|
.AddUserManager<MyUserManager>()
|
||||||
|
.AddUserStore<NoopUserStore>()
|
||||||
|
.AddRoleStore<NoopRoleStore>();
|
||||||
|
var thingy = services.BuildServiceProvider().GetRequiredService<IUserConfirmation<PocoUser>>() as MyUserConfirmation;
|
||||||
|
Assert.NotNull(thingy);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CanOverrideRoleValidator()
|
public void CanOverrideRoleValidator()
|
||||||
{
|
{
|
||||||
|
|
@ -356,5 +372,9 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class MyUserConfirmation : DefaultUserConfirmation<PocoUser>
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue