using Nop.Core; using Nop.Services.Authentication.External; using Nop.Web.Models.Customer; namespace Nop.Web.Factories; /// /// Represents the external authentication model factory /// public partial class ExternalAuthenticationModelFactory : IExternalAuthenticationModelFactory { #region Fields protected readonly IAuthenticationPluginManager _authenticationPluginManager; protected readonly IStoreContext _storeContext; protected readonly IWorkContext _workContext; #endregion #region Ctor public ExternalAuthenticationModelFactory(IAuthenticationPluginManager authenticationPluginManager, IStoreContext storeContext, IWorkContext workContext) { _authenticationPluginManager = authenticationPluginManager; _storeContext = storeContext; _workContext = workContext; } #endregion #region Methods /// /// Prepare the external authentication method model /// /// /// A task that represents the asynchronous operation /// The task result contains the list of the external authentication method model /// public virtual async Task> PrepareExternalMethodsModelAsync() { var store = await _storeContext.GetCurrentStoreAsync(); return (await _authenticationPluginManager .LoadActivePluginsAsync(await _workContext.GetCurrentCustomerAsync(), store.Id)) .Select(authenticationMethod => new ExternalAuthenticationMethodModel { ViewComponent = authenticationMethod.GetPublicViewComponent() }).Where(p => p.ViewComponent != null) .ToList(); } #endregion }