Revert "Remove IExternalLoginService.cs"

This reverts commit 8b2557817b.
This commit is contained in:
Nikolaj Geisle
2022-05-23 10:33:32 +02:00
parent 7a1e134978
commit 882de44e38
6 changed files with 97 additions and 6 deletions

View File

@@ -309,6 +309,7 @@ namespace Umbraco.Cms.Core.DependencyInjection
factory.GetRequiredService<IEventMessagesFactory>(),
factory.GetRequiredService<IExternalLoginWithKeyRepository>()
));
Services.AddUnique<IExternalLoginService>(factory => factory.GetRequiredService<ExternalLoginService>());
Services.AddUnique<IExternalLoginWithKeyService>(factory => factory.GetRequiredService<ExternalLoginService>());
Services.AddUnique<ILocalizedTextService>(factory => new LocalizedTextService(
factory.GetRequiredService<Lazy<LocalizedTextServiceFileSources>>(),

View File

@@ -13,7 +13,7 @@ using Umbraco.Extensions;
namespace Umbraco.Cms.Core.Services
{
public class ExternalLoginService : RepositoryService, IExternalLoginWithKeyService
public class ExternalLoginService : RepositoryService, IExternalLoginService, IExternalLoginWithKeyService
{
private readonly IExternalLoginWithKeyRepository _externalLoginRepository;

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using Umbraco.Cms.Core.Security;
namespace Umbraco.Cms.Core.Services
{
/// <summary>
/// Used to store the external login info
/// </summary>
[Obsolete("Use IExternalLoginServiceWithKey. This will be removed in Umbraco 10")]
public interface IExternalLoginService : IService
{
/// <summary>
/// Returns all user logins assigned
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
IEnumerable<IIdentityUserLogin> GetExternalLogins(int userId);
/// <summary>
/// Returns all user login tokens assigned
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
IEnumerable<IIdentityUserToken> GetExternalLoginTokens(int userId);
/// <summary>
/// Returns all logins matching the login info - generally there should only be one but in some cases
/// there might be more than one depending on if an administrator has been editing/removing members
/// </summary>
/// <param name="loginProvider"></param>
/// <param name="providerKey"></param>
/// <returns></returns>
IEnumerable<IIdentityUserLogin> Find(string loginProvider, string providerKey);
/// <summary>
/// Saves the external logins associated with the user
/// </summary>
/// <param name="userId">
/// The user associated with the logins
/// </param>
/// <param name="logins"></param>
/// <remarks>
/// This will replace all external login provider information for the user
/// </remarks>
void Save(int userId, IEnumerable<IExternalLogin> logins);
/// <summary>
/// Saves the external login tokens associated with the user
/// </summary>
/// <param name="userId">
/// The user associated with the tokens
/// </param>
/// <param name="tokens"></param>
/// <remarks>
/// This will replace all external login tokens for the user
/// </remarks>
void Save(int userId, IEnumerable<IExternalLoginToken> tokens);
/// <summary>
/// Deletes all user logins - normally used when a member is deleted
/// </summary>
/// <param name="userId"></param>
void DeleteUserLogins(int userId);
}
}

View File

@@ -29,7 +29,7 @@ namespace Umbraco.Cms.Core.Services
private readonly Lazy<IMemberTypeService>? _memberTypeService;
private readonly Lazy<IMemberGroupService>? _memberGroupService;
private readonly Lazy<INotificationService>? _notificationService;
private readonly Lazy<IExternalLoginWithKeyService>? _externalLoginService;
private readonly Lazy<IExternalLoginService>? _externalLoginService;
private readonly Lazy<IRedirectUrlService>? _redirectUrlService;
private readonly Lazy<IConsentService>? _consentService;
private readonly Lazy<IKeyValueService>? _keyValueService;
@@ -38,7 +38,7 @@ namespace Umbraco.Cms.Core.Services
/// <summary>
/// Initializes a new instance of the <see cref="ServiceContext"/> class with lazy services.
/// </summary>
public ServiceContext(Lazy<IPublicAccessService>? publicAccessService, Lazy<IDomainService>? domainService, Lazy<IAuditService>? auditService, Lazy<ILocalizedTextService>? localizedTextService, Lazy<ITagService>? tagService, Lazy<IContentService>? contentService, Lazy<IUserService>? userService, Lazy<IMemberService>? memberService, Lazy<IMediaService>? mediaService, Lazy<IContentTypeService>? contentTypeService, Lazy<IMediaTypeService>? mediaTypeService, Lazy<IDataTypeService>? dataTypeService, Lazy<IFileService>? fileService, Lazy<ILocalizationService>? localizationService, Lazy<IPackagingService>? packagingService, Lazy<IServerRegistrationService>? serverRegistrationService, Lazy<IEntityService>? entityService, Lazy<IRelationService>? relationService, Lazy<IMacroService>? macroService, Lazy<IMemberTypeService>? memberTypeService, Lazy<IMemberGroupService>? memberGroupService, Lazy<INotificationService>? notificationService, Lazy<IExternalLoginWithKeyService>? externalLoginService, Lazy<IRedirectUrlService>? redirectUrlService, Lazy<IConsentService>? consentService, Lazy<IKeyValueService>? keyValueService, Lazy<IContentTypeBaseServiceProvider>? contentTypeBaseServiceProvider)
public ServiceContext(Lazy<IPublicAccessService>? publicAccessService, Lazy<IDomainService>? domainService, Lazy<IAuditService>? auditService, Lazy<ILocalizedTextService>? localizedTextService, Lazy<ITagService>? tagService, Lazy<IContentService>? contentService, Lazy<IUserService>? userService, Lazy<IMemberService>? memberService, Lazy<IMediaService>? mediaService, Lazy<IContentTypeService>? contentTypeService, Lazy<IMediaTypeService>? mediaTypeService, Lazy<IDataTypeService>? dataTypeService, Lazy<IFileService>? fileService, Lazy<ILocalizationService>? localizationService, Lazy<IPackagingService>? packagingService, Lazy<IServerRegistrationService>? serverRegistrationService, Lazy<IEntityService>? entityService, Lazy<IRelationService>? relationService, Lazy<IMacroService>? macroService, Lazy<IMemberTypeService>? memberTypeService, Lazy<IMemberGroupService>? memberGroupService, Lazy<INotificationService>? notificationService, Lazy<IExternalLoginService>? externalLoginService, Lazy<IRedirectUrlService>? redirectUrlService, Lazy<IConsentService>? consentService, Lazy<IKeyValueService>? keyValueService, Lazy<IContentTypeBaseServiceProvider>? contentTypeBaseServiceProvider)
{
_publicAccessService = publicAccessService;
_domainService = domainService;
@@ -97,7 +97,7 @@ namespace Umbraco.Cms.Core.Services
IDomainService? domainService = null,
IMacroService? macroService = null,
IPublicAccessService? publicAccessService = null,
IExternalLoginWithKeyService? externalLoginService = null,
IExternalLoginService? externalLoginService = null,
IServerRegistrationService? serverRegistrationService = null,
IRedirectUrlService? redirectUrlService = null,
IConsentService? consentService = null,
@@ -250,7 +250,7 @@ namespace Umbraco.Cms.Core.Services
/// <summary>
/// Gets the ExternalLoginService.
/// </summary>
public IExternalLoginWithKeyService? ExternalLoginService => _externalLoginService?.Value;
public IExternalLoginService? ExternalLoginService => _externalLoginService?.Value;
/// <summary>
/// Gets the RedirectUrlService.

View File

@@ -89,6 +89,30 @@ namespace Umbraco.Cms.Core.Security
}
[Obsolete("Use non obsolete ctor")]
public BackOfficeUserStore(
ICoreScopeProvider scopeProvider,
IUserService userService,
IEntityService entityService,
IExternalLoginService externalLoginService,
IOptions<GlobalSettings> globalSettings,
IUmbracoMapper mapper,
BackOfficeErrorDescriber describer,
AppCaches appCaches)
: this(
scopeProvider,
userService,
entityService,
StaticServiceProvider.Instance.GetRequiredService<IExternalLoginWithKeyService>(),
StaticServiceProvider.Instance.GetRequiredService<IOptionsSnapshot<GlobalSettings>>(),
mapper,
describer,
appCaches,
StaticServiceProvider.Instance.GetRequiredService<ITwoFactorLoginService>())
{
}
/// <inheritdoc />
public override async Task<bool> GetTwoFactorEnabledAsync(BackOfficeIdentityUser user,
CancellationToken cancellationToken = default(CancellationToken))

View File

@@ -68,7 +68,7 @@ namespace Umbraco.Cms.Core.Security
ICoreScopeProvider scopeProvider,
IdentityErrorDescriber describer,
IPublishedSnapshotAccessor publishedSnapshotAccessor,
IExternalLoginWithKeyService externalLoginService)
IExternalLoginService externalLoginService)
: this(memberService, mapper, scopeProvider, describer, publishedSnapshotAccessor, StaticServiceProvider.Instance.GetRequiredService<IExternalLoginWithKeyService>(), StaticServiceProvider.Instance.GetRequiredService<ITwoFactorLoginService>())
{