Fixing that the OpenId User shape template has hidden the password change for local users too

This commit is contained in:
Lombiq
2018-08-30 01:24:17 +02:00
committed by Zoltán Lehóczky
parent c237420dbf
commit 64dc18bb40
4 changed files with 27 additions and 4 deletions

View File

@@ -227,6 +227,7 @@
<Compile Include="Providers\Google.cs" />
<Compile Include="ResourceManifest.cs" />
<Compile Include="Services\AzureActiveDirectory\IAzureActiveDirectoryService.cs" />
<Compile Include="Services\IOpenIdAuthenticationService.cs" />
<Compile Include="Services\Twitter\MissingSettingsBanner.cs" />
<Compile Include="Services\AzureActiveDirectory\MissingSettingsBanner.cs" />
<Compile Include="Services\AzureActiveDirectory\InMemoryCache.cs" />

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Orchard.OpenId.Services {
public interface IOpenIdAuthenticationService : IDependency {
bool IsLocalUser();
}
}

View File

@@ -12,7 +12,7 @@ using Orchard.Services;
namespace Orchard.OpenId.Services {
[OrchardFeature("Orchard.OpenId")]
public class OpenIdAuthenticationService : IAuthenticationService {
public class OpenIdAuthenticationService : IAuthenticationService, IOpenIdAuthenticationService {
private readonly ShellSettings _settings;
private readonly IClock _clock;
private readonly IMembershipService _membershipService;
@@ -103,7 +103,7 @@ namespace Orchard.OpenId.Services {
return _localAuthenticationUser = localUser;
}
private bool IsLocalUser() {
public bool IsLocalUser() {
var httpContext = _httpContextAccessor.Current();
if (httpContext.IsBackgroundContext()) {

View File

@@ -1,7 +1,18 @@
<div class="user-display">
@using System.Web.Mvc;
<div class="user-display">
@if (WorkContext.CurrentUser != null) {
IHtmlString userNameDisplayHtml;
if (WorkContext.Resolve<Orchard.OpenId.Services.IOpenIdAuthenticationService>().IsLocalUser()) {
userNameDisplayHtml = Html.Raw("<a href=\"" + @Url.Action("ChangePassword", new { Controller = "Account", Area = "Orchard.Users" }) + "\">" + Html.ItemDisplayText(WorkContext.CurrentUser) + "</a>");
}
else {
userNameDisplayHtml = Html.ItemDisplayText(WorkContext.CurrentUser);
}
<span class="user-actions welcome">
@T("Welcome, <strong>{0}</strong>!", Html.ItemDisplayText(WorkContext.CurrentUser))
@T("Welcome, <strong>{0}</strong>!", userNameDisplayHtml)
</span>
<span class="user-actions">
@Html.ActionLink(T("Sign Out").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }, new { rel = "nofollow" })