コード例 #1
0
        public JsonResult QuenMatKhau(string diaChiEmail)
        {
            int result = 0;

            tkB = new TaiKhoanBusiness();
            if (ModelState.IsValid)
            {
                List <TaiKhoan> dsTK = tkB.TaiKhoanDaTonTai(diaChiEmail);
                if (dsTK.Count == 0) //Tài khoản chưa tồn tài
                {
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                else if (dsTK.Count != 0 && dsTK[0].MatKhau == "")// Tài khoản đã tồn tại, nhưng đăng nhập facebook
                {
                    result = 1;
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                result = 2;//Tài khoản đã tồn tại
                string matKhauRandom = RandomString(5);
                string noiDungMail   = "<p> Mật khẩu của bạn đã được đổi thành </p> " + matKhauRandom;
                //Gửi mail
                GuiMail(diaChiEmail, "Đổi mật khẩu", noiDungMail);

                //Cập nhật lại mật khẩu
                string mkMoiHashed;
                using (MD5 md5hash = MD5.Create())
                {
                    mkMoiHashed = GetMd5Hash(md5hash, matKhauRandom);
                }
                dsTK[0].MatKhau = mkMoiHashed;
                tkB.TaiKhoan_Update(dsTK[0]);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
 public JsonResult ChinhSuaTaiKhoan(TaiKhoan t)
 {
     tkB = new TaiKhoanBusiness();
     tkB.TaiKhoan_Update(t);
     Session["Ten"] = t.Ten;
     return(Json(JsonRequestBehavior.AllowGet));
 }