Skip to content

Commit

Permalink
Make methods virtual so they can be redefined in derived classes.
Browse files Browse the repository at this point in the history
(cherry picked from commit ff3d8c1)
  • Loading branch information
jbreuer authored and nul800sebastiaan committed Mar 16, 2023
1 parent 5966ad4 commit 815eb5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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

0 comments on commit 815eb5b

Please sign in to comment.