Ejemplo n.º 1
0
        public ActionResult Send(FormCollection form)
        {
            if (Session["Account"] == null)
            {
                RedirectToAction("Index", "Login");
            }
            if ((int?)Session["AccountType"] != (int)TenantAccountType.Email)
            {
                RedirectToAction("Index", "Login");
            }
            var svc    = ServiceLocator.Resolve <IModelService>("Internal");
            var tenant = svc.Select(new TenantQuery()
            {
                Account = (string)Session["Account"]
            }).FirstOrDefault();
            var verify = new EmailVerify()
            {
                Code    = Guid.NewGuid().ToString().Hash(),
                Email   = tenant.Account,
                Name    = tenant.Name,
                ReferID = tenant.ID,
                Type    = (int)EmailVerifyTypes.TenantResetPwd,
                Returl  = ""
            };

            verify.Returl = new UriBuilder("http", Request.Url.Host, Request.Url.Port, "Forget/Verify",
                                           "?code=" + verify.Code).ToString();
            svc.Create(verify);
            Session["Account"]     = null;
            Session["AccountType"] = null;
            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public static void Send(Tenant t, HttpRequestBase request)
        {
            var svc = ServiceLocator.Resolve <IModelService>("Internal");

            if (t.EmailVerified == true)
            {
                return;
            }

            var current =
                svc.SelectOrEmpty(new EmailVerifyQuery()
            {
                ReferID        = t.ID.Value,
                Type           = (int)EmailVerifyTypes.TenantRegister,
                OrderDirection = OrderDirection.Desc,
                OrderField     = "ID"
            }).FirstOrDefault();

            if (current != null)
            {
                if (current.CreatedAt != null && (current.CreatedAt - DateTime.Now) < new TimeSpan(0, 10, 0))
                {
                    throw new RuleViolatedException("请10分钟后再试");
                }
                Guardian.Invoke(() => svc.Delete(current));
            }

            var verify = new EmailVerify()
            {
                Code    = Guid.NewGuid().ToString().Hash(),
                ReferID = t.ID,
                Type    = (int)EmailVerifyTypes.TenantRegister,
                Email   = t.Account,
                Name    = t.Name
            };
            var uri = new UriBuilder("http", request.Url.Host, request.Url.Port, "BindEmail",
                                     "?code=" + verify.Code);

            verify.Returl = uri.ToString();
            Guardian.Invoke(() => svc.Create(verify));
        }
Ejemplo n.º 3
0
        private void SendEmail(EmailVerify model, string userId)
        {
            string body = InitializerMail.GetHtmlTemplateString <EmailVerify>("~/Views/Shared/EmailVerify.cshtml", model);

            UserManager.SendEmailAsync(userId, "Подтверждение электронной почты", body);
        }
Ejemplo n.º 4
0
 static void Main(string[] args)
 {
     EmailVerify emailVerify = new EmailVerify(EmailVerify.GooglePublicDNS);
     var         isemailOK   = emailVerify.AskDNS(domain: "microsoft.com", email: "*****@*****.**");
 }