示例#1
0
        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);
            }
        }
示例#2
0
        /// <summary>
        /// Handles the Click event of the ValidateKey control.
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="EventArgs"/> instance containing the event data.
        /// </param>
        public void ValidateKey_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            var userRow   = this.GetRepository <CheckEmail>().Update(this.key.Text).Rows[0];
            var userEmail = userRow["Email"].ToString();

            var keyVerified = userRow["ProviderUserKey"] != DBNull.Value;

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

            if (!keyVerified)
            {
                return;
            }

            // approve and update e-mail in the membership as well...
            var user = UserMembershipHelper.GetMembershipUserByKey(userRow["ProviderUserKey"]);

            if (!user.IsApproved)
            {
                user.IsApproved = true;

                // Send welcome mail/pm to user
                this.Get <ISendNotification>().SendUserWelcomeNotification(user, userRow["UserID"].ToType <int>());
            }

            // update the email if anything was returned...
            if (user.Email != userEmail && userEmail != string.Empty)
            {
                user.Email = userEmail;
            }

            // tell the provider to update...
            this.Get <MembershipProvider>().UpdateUser(user);

            // now redirect to main site...
            this.PageContext.LoadMessage.AddSession(this.GetText("EMAIL_VERIFIED"), MessageTypes.Information);

            // default redirect -- because if may not want to redirect to login.
            YafBuildLink.Redirect(ForumPages.forum);
        }