0
votes

hi i am working on Umbraco(6.1.2) membership system ive made login ,registration, and authentication page after registeration user is redirected to authentication page with token_id

now i want to set this user approved for this purpose i write the following code but there is some error check it

string uname = Request.QueryString["a"];
string uguid = Request.QueryString["b"];

MembershipUser thisUser = Membership.GetUser(uname);
if (thisUser != null)
{
if (!thisUser.IsApproved)
{
MemberProfile mp = MemberProfile.GetUserProfile(uname);
if (mp != null)
{
if (mp.AuthGuid == uguid)
{
thisUser.IsApproved = true;
Membership.UpdateUser(thisUser);
lblMessage.Text = "Thank you for confirming your email address";
}
else
{
lblMessage.Text = "Error confirming your email address";
}
}
else
{
lblMessage.Text = "Error confirming your email address";
}
}
else
{
lblMessage.Text = "Email address is already confirmed";
}
}

control is return to else condition from this condition "if (!thisUser.IsApproved)"

and also if i reverse the condition it gets into if block and executes all commands without errors but still not mark user as approved

plz help me

Refrence:Authenticating new members before activating

1
What is the error that is being thrown? Can you post the stack trace of this too?Digbyswift
it is not throwing any errorMohsin

1 Answers

0
votes

I had problem with approved as well.

Now I just use this in my code:

MembershipUser user = Membership.GetUser(nodeIdOrUsername);
user.IsApproved = true;
Membership.UpdateUser(user);

You may also need to add a property to your Member type, eg. isApproved and then add it to your provider in web.config in profile > properties section:

<add name="isApproved" allowAnonymous="false" provider="UmbracoMembershipProvider" type="System.Boolean"/>

and then extend ProfileBase and added an Approved property. In web.config in membership > provider section add this property to your provider key eg.:

<add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" umbracoApprovePropertyTypeAlias="isApproved" umbracoLockPropertyTypeAlias="isLocked" ... />

I can't remember for sure but I think without it it didn't work.

I hope this will be of any use.