-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce AddUsers() extension method (#12932)
- Loading branch information
Showing
2 changed files
with
45 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/OrchardCore/OrchardCore.Users.Core/Extensions/UsersServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using OrchardCore.Users.Services; | ||
using OrchardCore.Users; | ||
using OrchardCore.Users.Indexes; | ||
using YesSql.Indexes; | ||
using OrchardCore.Users.Handlers; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
/// <summary> | ||
/// Provides extension methods for <see cref="IServiceCollection"/>. | ||
/// </summary> | ||
public static class UsersServiceCollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Registers the users services. | ||
/// </summary> | ||
/// <param name="services">The <see cref="IServiceCollection"/>.</param> | ||
public static IServiceCollection AddUsers(this IServiceCollection services) | ||
{ | ||
services.TryAddScoped<UserStore>(); | ||
services.TryAddScoped<IUserStore<IUser>>(sp => sp.GetRequiredService<UserStore>()); | ||
services.TryAddScoped<IUserRoleStore<IUser>>(sp => sp.GetRequiredService<UserStore>()); | ||
services.TryAddScoped<IUserPasswordStore<IUser>>(sp => sp.GetRequiredService<UserStore>()); | ||
services.TryAddScoped<IUserEmailStore<IUser>>(sp => sp.GetRequiredService<UserStore>()); | ||
services.TryAddScoped<IUserSecurityStampStore<IUser>>(sp => sp.GetRequiredService<UserStore>()); | ||
services.TryAddScoped<IUserLoginStore<IUser>>(sp => sp.GetRequiredService<UserStore>()); | ||
services.TryAddScoped<IUserClaimStore<IUser>>(sp => sp.GetRequiredService<UserStore>()); | ||
services.TryAddScoped<IUserAuthenticationTokenStore<IUser>>(sp => sp.GetRequiredService<UserStore>()); | ||
|
||
services.AddSingleton<IIndexProvider, UserIndexProvider>(); | ||
services.AddSingleton<IIndexProvider, UserByRoleNameIndexProvider>(); | ||
services.AddSingleton<IIndexProvider, UserByLoginInfoIndexProvider>(); | ||
services.AddSingleton<IIndexProvider, UserByClaimIndexProvider>(); | ||
|
||
services.AddScoped<IUserService, UserService>(); | ||
services.AddScoped<IUserClaimsPrincipalFactory<IUser>, DefaultUserClaimsPrincipalProviderFactory>(); | ||
services.AddScoped<IUserEventHandler, UserDisabledEventHandler>(); | ||
|
||
return services; | ||
} | ||
} | ||
} |