示例#1
0
        private void ResendEmail()
        {
            m_NeedActive = true;

            MessageDisplay msgDisplay = CreateMessageDisplay();

            int userID = _Request.Get <int>("userid", Method.All, 0);
            ValidateEmailAction emailType = (ValidateEmailAction)_Request.Get <ValidateEmailAction>("type", Method.Get, ValidateEmailAction.ActivingUser);
            string code = _Request.Get("code", Method.Get, string.Empty);

            using (ErrorScope es = new ErrorScope())
            {
                bool suceess;
                //= UserBO.Instance.SendEmail(userID, code, emailType);

                if (emailType == ValidateEmailAction.ActivingUser)
                {
                    suceess = UserBO.Instance.TryActiveUser(userID, code);
                }
                else
                {
                    suceess = UserBO.Instance.TryValidateEmail(userID, code);
                }

                if (suceess == false)
                {
                    if (es.HasUnCatchedError)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            IsOverrunLimitTimes = true;
                            msgDisplay.AddError(error);
                        });
                    }
                    else
                    {
                        ShowError("无效的用户ID或验证码!");
                    }
                }
            }

            //m_NeedActive = true;
            //int userID = _Request.Get<int>("userid", Method.All, 0);
            //ValidateEmailAction emailType = (ValidateEmailAction)_Request.Get<ValidateEmailAction>("resend", Method.Get, ValidateEmailAction.ActivingUser);
            //string code = _Request.Get("code", Method.Get, string.Empty);
            //bool success = UserBO.Instance.SendEmail(userID, code, emailType);
            //return success;
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AddNavigationItem("注册新帐号");

#if !Passport
            PassportClientConfig setting = Globals.PassportClient;
            if (setting.EnablePassport)
            {
                Response.Redirect(setting.RegisterUrl);
                return;
            }
#endif

            activeCode = _Request.Get("active", Method.Get);

            MessageDisplay      msgDisplay        = CreateMessageDisplay();
            ValidateEmailAction activingEmailType = _Request.Get <ValidateEmailAction>("type", Method.Get, ValidateEmailAction.None);
            int isSent = _Request.Get("issent", Method.Get, 0);
            if (activingEmailType != ValidateEmailAction.None)
            {
                if (activingEmailType == ValidateEmailAction.ActivingUser)
                {
                    IsActivingUser = true;
                }
                else
                {
                    IsValidateEmail = true;
                }
                m_NeedActive = true;
                int userID = _Request.Get <int>("userid", Method.Get, 0);
                NeedActiveUser = UserBO.Instance.GetUser(userID);
                if (NeedActiveUser == null)
                {
                    ShowError("该用户ID可能已经被删除,请重新注册!");
                }
                m_email = NeedActiveUser.Email;
                CheckEmailLoginLink(m_email);
            }


            //判断用户是否点击了“注册”按钮
            if (_Request.IsClick("register"))
            {
                Register();
            }
            //判断用户是否点击了"重新发送邮件"按钮
            else if (_Request.IsClick("sendmail"))
            {
                ResendEmail();
            }
            //判断是否“激活帐号”操作
            else if (!string.IsNullOrEmpty(activeCode))
            {
                if (_Request.IsClick("activeme"))  //这里加点击按钮判断是因为某些邮箱会抓取邮件里的链接,造成用户自动激活。
                {
                    using (ErrorScope es = new ErrorScope())
                    {
                        if (UserBO.Instance.ActivingUser(activeCode))
                        {
                            //用户激活成功
                            ShowSuccess("恭喜!您的账号" + My.Username + "已成功激活。", IndexUrl);
                        }
                        else
                        {
                            if (es.HasUnCatchedError)
                            {
                                es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                                {
                                    IsOverrunLimitTimes = true;
                                    msgDisplay.AddError(error);
                                });
                            }
                            else
                            {
                                ShowError(new InvalidActiveCodeError("active", activeCode));
                            }
                        }
                    }
                }
            }

            //判断是否“重发激活邮件”的操作
            else if (activingEmailType == ValidateEmailAction.ActivingUser && isSent != 1)
            {
                NeedSendMailClick = true;
            }
            //判断是否"重新发送验证邮箱的邮件"
            else if (activingEmailType == ValidateEmailAction.ValidateEmail && isSent != 1)
            {
                NeedSendMailClick = true;
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type">发送验证email邮件的类型</param>
        /// <param name="userID">用户ID</param>
        /// <param name="password">已经入库的、加密后的密码</param>
        /// <param name="isSent">是否已经发出了邮件,如果是,则不需要进入提示用户发送邮件的界面</param>
        /// <returns></returns>
        public static string GetSendEmailUrl(ValidateEmailAction type, int userID, string encodedPassword, bool isSent)
        {
            string code = SecurityUtil.SHA1(encodedPassword + Globals.SafeString);

            return(BbsRouter.GetUrl("register", string.Format("type={0}&userid={1}&code={2}&issent={3}", (int)type, userID, code, isSent ? 1 : 0)));
        }
示例#4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="type">发送验证email邮件的类型</param>
 /// <param name="userID">用户ID</param>
 /// <param name="password">已经入库的、加密后的密码</param>
 /// <param name="isSent">是否已经发出了邮件,如果是,则不需要进入提示用户发送邮件的界面</param>
 /// <returns></returns>
 public static string GetSendEmailUrl(ValidateEmailAction type,int userID,string encodedPassword, bool isSent)
 {
     string code = SecurityUtil.SHA1(encodedPassword + Globals.SafeString);
     return BbsRouter.GetUrl("register", string.Format("type={0}&userid={1}&code={2}&issent={3}", (int)type, userID, code, isSent ? 1 : 0));
 }