I'm using MemberService to create members for a website, which was working. I have a new requirement to add token based validation of a user, so the account is created setting IsApproved = false, waiting for a hit a Surface Controller with a valid token to approve the user.
If the user is set IsApproved = false, then I can't load them up with memberService.GetByUsername(). I can load up the member with the MembershipHelper, but this provides me read-only access to member data.
I can get around this by adding my own property IsValidated, but think that I am duplicating the work that Umbraco is already doing, so I think I am missing something. Is there a way to programmatically set IsApproved for existing members and use the in-built functionality?
when a members property IsApproved is set to false, it normally will also be taken by the method ´GetByUsername()´. If I look into the source code I don't see any checks for only returning the Member when he is approved.
So normally using this code it would work:
private IMemberService MemberService
{
get
{
return Services.MemberService;
}
}
public void SetMemberApproved(string username) {
var member = MemberService.GetByUsername(username);
member.IsApproved = true;
MemberService.Save(member);
}
Thanks Michaël, looking further it seems to be some confusion between the properties that I was using for Login and Email which were two different values. I think my debugging lead me to a false conclusion, I've managed to get this working now.
Loading unapproved Members and approving by token
I'm using MemberService to create members for a website, which was working. I have a new requirement to add token based validation of a user, so the account is created setting
IsApproved = false
, waiting for a hit a Surface Controller with a valid token to approve the user.If the user is set
IsApproved = false
, then I can't load them up withmemberService.GetByUsername()
. I can load up the member with the MembershipHelper, but this provides me read-only access to member data.I can get around this by adding my own property
IsValidated
, but think that I am duplicating the work that Umbraco is already doing, so I think I am missing something. Is there a way to programmatically setIsApproved
for existing members and use the in-built functionality?Hi Colin,
when a members property
IsApproved
is set to false, it normally will also be taken by the method ´GetByUsername()´. If I look into the source code I don't see any checks for only returning the Member when he is approved.So normally using this code it would work:
Hope this helps.
/Michaël
Thanks Michaël, looking further it seems to be some confusion between the properties that I was using for Login and Email which were two different values. I think my debugging lead me to a false conclusion, I've managed to get this working now.
C
Colin,
glad that you have solved it!
Have a nice day and enjoy Umbraco!
/Michaël
is working on a reply...