Umbraco Identity - how to create a member within a custom member type
Hi,
I am using the UmbracoIdentity package and am trying to register a member to an alternative member type. I have created the member type in Umbraco and followed the in-code comments in the 'Register' view. Therefore I have initialised the register model like so:
var registerModel = Members.CreateRegistrationModel("MyMemberTypeAlias");
However when I register the member they still get added to the 'Member' member type. Looking at the code I think this is because the UmbracoIdentityAccountController HandleRegisterMember action doesn't do anything with the model's MemberTypeAlias. The UmbracoApplicationMember doesn't appear to have any properties that I can use to assign the alternative MemberTypeAlias either.
How can I register a member to a custom member type?
I worked out an alternative registration process using the member service to achieve what I wanted. My register member action method now looks like this:
[HttpPost]
[AllowAnonymous]
public async Task<ActionResult> HandleRegisterMember([Bind(Prefix = "registerModel")]RegisterModel model)
{
if (ModelState.IsValid == false)
{
return CurrentUmbracoPage();
}
var username = model.UsernameIsEmail || model.Username == null ? model.Email : model.Username;
var memberService = Services.MemberService;
if (memberService.GetByUsername(username) == null)
{
//register member
var member = memberService.CreateMember(username, model.Email, model.Name, model.MemberTypeAlias);
memberService.Save(member);
memberService.SavePassword(member, model.Password);
//authenticate member
var user = await UserManager.FindAsync(username, model.Password);
if (user != null)
{
await SignInAsync(user, isPersistent: false);
//if there is a specified path to redirect to then use it
if (!model.RedirectUrl.IsNullOrWhiteSpace())
{
return Redirect(model.RedirectUrl);
}
//redirect to current page by default
return RedirectToCurrentUmbracoPage();
}
}
else
{
//username already exists
ModelState.AddModelError("registerModel", "The email address provided has already been registered");
}
return CurrentUmbracoPage();
}
Umbraco Identity - how to create a member within a custom member type
Hi,
I am using the UmbracoIdentity package and am trying to register a member to an alternative member type. I have created the member type in Umbraco and followed the in-code comments in the 'Register' view. Therefore I have initialised the register model like so:
However when I register the member they still get added to the 'Member' member type. Looking at the code I think this is because the UmbracoIdentityAccountController HandleRegisterMember action doesn't do anything with the model's MemberTypeAlias. The UmbracoApplicationMember doesn't appear to have any properties that I can use to assign the alternative MemberTypeAlias either.
How can I register a member to a custom member type?
Thanks,
Nathan
I worked out an alternative registration process using the member service to achieve what I wanted. My register member action method now looks like this:
Hi can you please create an issue/PR for this so it can be resolved in the library? https://github.com/Shazwazza/UmbracoIdentity
No probs. I'll get on it now.
is working on a reply...