Approve member when created with built-in macros (#10428)
* Allow members created with built-in macros to be approved * Cleanup * Newly created members are always approved like in v8. Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
committed by
GitHub
parent
c63b14a52e
commit
0c3db013d5
@@ -34,7 +34,7 @@ namespace Umbraco.Cms.Core.Security
|
||||
/// <summary>
|
||||
/// Used to construct a new instance without an identity
|
||||
/// </summary>
|
||||
public static MemberIdentityUser CreateNew(string username, string email, string memberTypeAlias, string name = null)
|
||||
public static MemberIdentityUser CreateNew(string username, string email, string memberTypeAlias, bool isApproved, string name = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(username))
|
||||
{
|
||||
@@ -46,6 +46,7 @@ namespace Umbraco.Cms.Core.Security
|
||||
user.UserName = username;
|
||||
user.Email = email;
|
||||
user.MemberTypeAlias = memberTypeAlias;
|
||||
user.IsApproved = isApproved;
|
||||
user.Id = null;
|
||||
user.HasIdentity = false;
|
||||
user.Name = name;
|
||||
|
||||
@@ -366,6 +366,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
contentItem.Username,
|
||||
contentItem.Email,
|
||||
memberType.Alias,
|
||||
contentItem.IsApproved,
|
||||
contentItem.Name);
|
||||
|
||||
IdentityResult created = await _memberManager.CreateAsync(identityMember, contentItem.Password.NewPassword);
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Umbraco.Cms.Web.Website.Controllers
|
||||
|
||||
model.Username = (model.UsernameIsEmail || model.Username == null) ? model.Email : model.Username;
|
||||
|
||||
var identityUser = MemberIdentityUser.CreateNew(model.Username, model.Email, model.MemberTypeAlias, model.Name);
|
||||
var identityUser = MemberIdentityUser.CreateNew(model.Username, model.Email, model.MemberTypeAlias, true, model.Name);
|
||||
IdentityResult identityResult = await _memberManager.CreateAsync(
|
||||
identityUser,
|
||||
model.Password);
|
||||
@@ -142,6 +142,7 @@ namespace Umbraco.Cms.Web.Website.Controllers
|
||||
// should never happen
|
||||
throw new InvalidOperationException($"Could not find a member with key: {member.Key}.");
|
||||
}
|
||||
|
||||
if (model.MemberProperties != null)
|
||||
{
|
||||
foreach (MemberPropertyModel property in model.MemberProperties.Where(p => p.Value != null)
|
||||
@@ -159,7 +160,6 @@ namespace Umbraco.Cms.Web.Website.Controllers
|
||||
}
|
||||
|
||||
return identityResult;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user