approve user umbraco membership system

为君一笑 提交于 2019-12-13 21:18:56

问题


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:


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.



来源:https://stackoverflow.com/questions/17568681/approve-user-umbraco-membership-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!