•  tommy382
  • 100% (Exalted)
  • YAF Commander Topic Starter
Affected versions: 1.9.4Final & 1.9.5RC1.

When a new user sign up and require email validation, the user get an email with the activation link. However, if an ADMIN approved that user before the user click on the validation link in the email, the user will get a message saying "failed to validate your email" when he click on the validation link.

In this case, I would say "validation success" instead of failure. I had to add the code in yellow below to make it less confusing to the user seeing the "validation failed" message.

public void ValidateKey_Click( object sender, System.EventArgs e )
DataTable dt = YAF.Classes.Data.DB.checkemail_update( key.Text );
DataRow row = dt.Rows [0];
string dbEmail = row ["Email"].ToString();

bool keyVerified = ( row["ProviderUserKey"] == DBNull.Value ) ? false : true;

approved.Visible = keyVerified;
error.Visible = !keyVerified;

if ( keyVerified )
// approve and update e-mail in the membership as well...
System.Web.Security.MembershipUser user = UserMembershipHelper.GetMembershipUserByKey( row ["ProviderUserKey"] );
if (!user.IsApproved) user.IsApproved = true;
// update the email if anything was returned...
if (user.Email != dbEmail && dbEmail != "" ) user.Email = dbEmail;
// tell the provider to update...
PageContext.CurrentMembership.UpdateUser( user );

// now redirect to login...
PageContext.LoadMessage.AddSession( GetText( "EMAIL_VERIFIED" ) );

YafBuildLink.Redirect( ForumPages.login );
PageContext.AddLoadMessage("Failed to verify your email but try to login anyway, an Admin might approved your account already.");

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved