Skip to content

Commit

Permalink
PT-13784: Add logoUrl (#2700)
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOkhriemnko authored Sep 29, 2023
1 parent a187863 commit a01c2de
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ public class ExternalSignInProviderConfiguration
/// Provider implementation
/// </summary>
public IExternalSignInProvider Provider { get; set; }

/// <summary>
/// Provider logo url (ex '/Modules/$(ModuleId)/Content/provider-logo.png')
/// </summary>
public string LogoUrl { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using VirtoCommerce.Platform.Core.Common;
using VirtoCommerce.Platform.Core.Events;
using VirtoCommerce.Platform.Core.Security;
using VirtoCommerce.Platform.Core.Security.Events;
using VirtoCommerce.Platform.Security.ExternalSignIn;
using VirtoCommerce.Platform.Web.Model.Security;

namespace VirtoCommerce.Platform.Web.Controllers
Expand All @@ -17,14 +20,17 @@ public class ExternalSignInController : Controller
private readonly SignInManager<ApplicationUser> _signInManager;
private readonly IExternalSigninService _externalSigninService;
private readonly IEventPublisher _eventPublisher;
private readonly IEnumerable<ExternalSignInProviderConfiguration> _externalSigninProviderConfigs;

public ExternalSignInController(SignInManager<ApplicationUser> signInManager,
IExternalSigninService externalSigninService,
IEventPublisher eventPublisher)
IEventPublisher eventPublisher,
IEnumerable<ExternalSignInProviderConfiguration> externalSigninProviderConfigs)
{
_signInManager = signInManager;
_externalSigninService = externalSigninService;
_eventPublisher = eventPublisher;
_externalSigninProviderConfigs = externalSigninProviderConfigs;
}

[HttpGet]
Expand Down Expand Up @@ -80,7 +86,10 @@ public async Task<ActionResult<ExternalSignInProviderInfo[]>> GetExternalLoginPr
.Select(authenticationDescription => new ExternalSignInProviderInfo
{
AuthenticationType = authenticationDescription.Name,
DisplayName = authenticationDescription.DisplayName
DisplayName = authenticationDescription.DisplayName,
LogoUrl = _externalSigninProviderConfigs?
.FirstOrDefault(x => x.AuthenticationType.EqualsInvariant(authenticationDescription.Name))?
.LogoUrl,
})
.ToArray();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public class ExternalSignInProviderInfo
{
public string AuthenticationType { get; set; }
public string DisplayName { get; set; }
public string LogoUrl { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h1 class="auth__title">{{ 'platform.blades.login.labels.sign-in' | translate: (
</div>
<div class="socials" ng-if="loginProviders.length && !loginProgress">
<a href="#" class="vc-button-social" ng-repeat="provider in loginProviders" ng-click="$event.preventDefault();externalLogin(provider);">
<img class="vc-button-social__img" ng-src="/images/{{provider.authenticationType}}.webp" onerror="this.style.display = 'none';" alt="">
<img class="vc-button-social__img" ng-src="{{provider.logoUrl}}" onerror="this.style.display = 'none';" ng-if="provider.logoUrl" alt="">
<div class="vc-button-social__text">{{ provider.displayName }}</div>
</a>
</div>
Expand Down

0 comments on commit a01c2de

Please sign in to comment.