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

Make methods virtual so they can be redefined in derived classes. #13752

Merged
merged 1 commit into from Jan 31, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Umbraco.Web.Common/Security/MemberManager.cs
Expand Up @@ -50,7 +50,7 @@ public class MemberManager : UmbracoUserManager<MemberIdentityUser, MemberPasswo
}

/// <inheritdoc />
public async Task<bool> IsMemberAuthorizedAsync(
public virtual async Task<bool> IsMemberAuthorizedAsync(
IEnumerable<string>? allowTypes = null,
IEnumerable<string>? allowGroups = null,
IEnumerable<int>? allowMembers = null)
Expand Down Expand Up @@ -122,14 +122,14 @@ public class MemberManager : UmbracoUserManager<MemberIdentityUser, MemberPasswo
}

/// <inheritdoc />
public bool IsLoggedIn()
public virtual bool IsLoggedIn()
{
HttpContext? httpContext = _httpContextAccessor.HttpContext;
return httpContext?.User.Identity?.IsAuthenticated ?? false;
}

/// <inheritdoc />
public async Task<bool> MemberHasAccessAsync(string path)
public virtual async Task<bool> MemberHasAccessAsync(string path)
{
if (await IsProtectedAsync(path))
{
Expand All @@ -140,7 +140,7 @@ public async Task<bool> MemberHasAccessAsync(string path)
}

/// <inheritdoc />
public async Task<IReadOnlyDictionary<string, bool>> MemberHasAccessAsync(IEnumerable<string> paths)
public virtual async Task<IReadOnlyDictionary<string, bool>> MemberHasAccessAsync(IEnumerable<string> paths)
{
IReadOnlyDictionary<string, bool> protectedPaths = await IsProtectedAsync(paths);

Expand All @@ -163,10 +163,10 @@ public async Task<bool> MemberHasAccessAsync(string path)
/// <remarks>
/// this is a cached call
/// </remarks>
public Task<bool> IsProtectedAsync(string path) => Task.FromResult(_publicAccessService.IsProtected(path).Success);
public virtual Task<bool> IsProtectedAsync(string path) => Task.FromResult(_publicAccessService.IsProtected(path).Success);

/// <inheritdoc />
public Task<IReadOnlyDictionary<string, bool>> IsProtectedAsync(IEnumerable<string> paths)
public virtual Task<IReadOnlyDictionary<string, bool>> IsProtectedAsync(IEnumerable<string> paths)
{
var result = new Dictionary<string, bool>();
foreach (var path in paths)
Expand All @@ -179,7 +179,7 @@ public async Task<bool> MemberHasAccessAsync(string path)
}

/// <inheritdoc />
public async Task<MemberIdentityUser?> GetCurrentMemberAsync()
public virtual async Task<MemberIdentityUser?> GetCurrentMemberAsync()
{
if (_currentMember == null)
{
Expand All @@ -194,7 +194,7 @@ public async Task<bool> MemberHasAccessAsync(string path)
return _currentMember;
}

public IPublishedContent? AsPublishedMember(MemberIdentityUser user) => _store.GetPublishedMember(user);
public virtual IPublishedContent? AsPublishedMember(MemberIdentityUser user) => _store.GetPublishedMember(user);

/// <summary>
/// This will check if the member has access to this path
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Web.Common/Security/MemberSignInManager.cs
Expand Up @@ -126,7 +126,7 @@ public class MemberSignInManager : UmbracoSignInManager<MemberIdentityUser>, IMe
/// <summary>
/// Custom ExternalLoginSignInAsync overload for handling external sign in with auto-linking
/// </summary>
public async Task<SignInResult> ExternalLoginSignInAsync(ExternalLoginInfo loginInfo, bool isPersistent, bool bypassTwoFactor = false)
public virtual async Task<SignInResult> ExternalLoginSignInAsync(ExternalLoginInfo loginInfo, bool isPersistent, bool bypassTwoFactor = false)
{
// borrowed from https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs
// to be able to deal with auto-linking and reduce duplicate lookups
Expand Down