예제 #1
0
    //点击修改密码,向用户发送激活账户的邮件
    //并且修改用户的验证码,自动生成随机字符串
    protected void ResetPassword_Click(object sender, EventArgs e)
    {
        HttpCookie  cookie  = Request.Cookies["usr"];
        StudentInfo student = bllStudent.Get(Convert.ToInt32(cookie.Values["ID"]));

        student.Stu_Password = Password1.Text.Trim();
        if (bllStudent.CheckLogin(student) && Password2.Text.Trim().Equals(Password3.Text.Trim()))
        {
            student.Stu_Password   = Md5Support.GetMd5String(Password2.Text.Trim());
            student.Stu_Validation = Str(10, false);
            bllStudent.Modify(student);
            try
            {
                String        strSmtpServer = "smtp.163.com";
                String        strFrom       = "*****@*****.**";
                String        strFromPass   = "******";
                String        strTo         = student.Stu_Email;
                String        strSubject    = "Viki账号激活";
                StringBuilder sb            = new StringBuilder();


                //邮件内容
                sb.AppendFormat("点击下面链接激活账号,否则重新注册账号,链接只能使用一次,请尽快激活!</br>");
                sb.AppendFormat("<a href='http://{0}/WebFrontEnd/Student/MailValidateSuccess.aspx?userName={1}&validateCode={2}''>点击这里</a></br>", Request.Url.Authority, student.Stu_ID, student.Stu_Validation);
                sb.AppendFormat("如未能激活请点击下面链接:<a href='http://{0}/WebFrontEnd/Student/MailValidateSuccess.aspx?userName={1}&validateCode={2}'>{3}/Student/MailValidateSuccess.aspx?userName={4}&validateCode={5}</a></br>", Request.Url.Authority, student.Stu_ID, student.Stu_Validation, Server.UrlPathEncode(Request.ApplicationPath), student.Stu_ID, student.Stu_Validation);
                SendSMTPEMail(strSmtpServer, strFrom, strFromPass, strTo, strSubject, sb.ToString());
                Response.Redirect("~/Student/Login.aspx");
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.Data);
                throw ex;
            }
        }
    }
예제 #2
0
파일: Student.cs 프로젝트: Ideal2014/Ideal
        //登录验证,验证用户的密码和是否为激活状态
        bool IBLL.IStudent.CheckLogin(StudentInfo s1)
        {
            s1.Stu_Password = Md5Support.GetMd5String(s1.Stu_Password);
            StudentInfo s2 = dal.Get(s1.Stu_ID);

            if (s2 == null || s1 == null)
            {
                return(false);
            }
            if (s2.Stu_Validation == null)
            {
                return(false);
            }
            return(s2.Stu_Password.Equals(s1.Stu_Password) && (s2.Stu_Validation.Equals("success")));
        }