Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9412 from AndyButland/feature/membership-helper-f…
…acade NetCore: Creates abstraction for membership helper and migrates controllers now dependent on it.
- Loading branch information
Showing
27 changed files
with
422 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Umbraco.Core/Models/PostRedirectModel.cs → ...Core/Models/Security/PostRedirectModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/Umbraco.Core/Security/HybridUmbracoWebsiteSecurityAccessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Umbraco.Core.Cache; | ||
using Umbraco.Web; | ||
|
||
namespace Umbraco.Core.Security | ||
{ | ||
|
||
public class HybridUmbracoWebsiteSecurityAccessor : HybridAccessorBase<IUmbracoWebsiteSecurity>, IUmbracoWebsiteSecurityAccessor | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HybridUmbracoWebsiteSecurityAccessor"/> class. | ||
/// </summary> | ||
public HybridUmbracoWebsiteSecurityAccessor(IRequestCache requestCache) | ||
: base(requestCache) | ||
{ } | ||
|
||
/// <inheritdoc /> | ||
protected override string ItemKey => "Umbraco.Web.HybridUmbracoWebsiteSecurityAccessor"; | ||
|
||
/// <summary> | ||
/// Gets or sets the <see cref="IUmbracoWebsiteSecurity"/> object. | ||
/// </summary> | ||
public IUmbracoWebsiteSecurity WebsiteSecurity | ||
{ | ||
get => Value; | ||
set => Value = value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Umbraco.Core.Models.Security; | ||
|
||
namespace Umbraco.Core.Security | ||
{ | ||
public interface IUmbracoWebsiteSecurity | ||
{ | ||
/// <summary> | ||
/// Registers a new member. | ||
/// </summary> | ||
/// <param name="model">Register member model.</param> | ||
/// <param name="logMemberIn">Flag for whether to log the member in upon successful registration.</param> | ||
/// <returns>Result of registration operation.</returns> | ||
Task<RegisterMemberStatus> RegisterMemberAsync(RegisterModel model, bool logMemberIn = true); | ||
|
||
/// <summary> | ||
/// Updates the currently logged in member's profile. | ||
/// </summary> | ||
/// <param name="model">Update member profile model.</param> | ||
/// <returns>Result of update profile operation.</returns> | ||
Task<UpdateMemberProfileResult> UpdateMemberProfileAsync(ProfileModel model); | ||
|
||
/// <summary> | ||
/// A helper method to perform the validation and logging in of a member. | ||
/// </summary> | ||
/// <param name="username">The username.</param> | ||
/// <param name="password">The password.</param> | ||
/// <returns>Result of login operation.</returns> | ||
Task<bool> LoginAsync(string username, string password); | ||
|
||
/// <summary> | ||
/// Check if a member is logged in | ||
/// </summary> | ||
/// <returns>True if logged in, false if not.</returns> | ||
bool IsLoggedIn(); | ||
|
||
/// <summary> | ||
/// Logs out the current member. | ||
/// </summary> | ||
Task LogOutAsync(); | ||
|
||
/// <summary> | ||
/// Checks if the current member is authorized based on the parameters provided. | ||
/// </summary> | ||
/// <param name="allowTypes">Allowed types.</param> | ||
/// <param name="allowGroups">Allowed groups.</param> | ||
/// <param name="allowMembers">Allowed individual members.</param> | ||
/// <returns>True or false if the currently logged in member is authorized</returns> | ||
bool IsMemberAuthorized( | ||
IEnumerable<string> allowTypes = null, | ||
IEnumerable<string> allowGroups = null, | ||
IEnumerable<int> allowMembers = null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Umbraco.Core.Security | ||
{ | ||
public interface IUmbracoWebsiteSecurityAccessor | ||
{ | ||
IUmbracoWebsiteSecurity WebsiteSecurity { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Umbraco.Core.Security | ||
{ | ||
public enum RegisterMemberStatus | ||
{ | ||
Success, | ||
InvalidUserName, | ||
InvalidPassword, | ||
InvalidEmail, | ||
DuplicateUserName, | ||
DuplicateEmail, | ||
Error, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace Umbraco.Core.Security | ||
{ | ||
public class UpdateMemberProfileResult | ||
{ | ||
private UpdateMemberProfileResult() | ||
{ | ||
} | ||
|
||
public UpdateMemberProfileStatus Status { get; private set; } | ||
|
||
public string ErrorMessage { get; private set; } | ||
|
||
public static UpdateMemberProfileResult Success() | ||
{ | ||
return new UpdateMemberProfileResult { Status = UpdateMemberProfileStatus.Success }; | ||
} | ||
|
||
public static UpdateMemberProfileResult Error(string message) | ||
{ | ||
return new UpdateMemberProfileResult { Status = UpdateMemberProfileStatus.Error, ErrorMessage = message }; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Umbraco.Core.Security | ||
{ | ||
public enum UpdateMemberProfileStatus | ||
{ | ||
Success, | ||
Error, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.