Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PT-13784: Add logoUrl #2700

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading