Beispiel #1
0
        public async Task <ActionResult> LiveRegister(RegisterLiveViewModel model)
        {
            if (ModelState.IsValid && new reCAPTCHAHelper().Validate(Request["g-recaptcha-response"]))
            {
                var user = new ApplicationUser {
                    UserName = model.Name, Email = model.Email, Name = model.Name, RegistrationDate = DateTime.Now
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // 傳送包含此連結的電子郵件
                    //string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    //var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    //await UserManager.SendEmailAsync(user.Id, "熊i猜Email驗證信", "請按此連結確認您的帳戶 <a href=\"" + callbackUrl + "\">驗證</a>");
                    await new AccountModel().RegisterFinsh(user);

                    /* var content = "<h2 style='text-align: center;'>申請通知信</h2>" +
                     * "<div style='text-align: center;padding:0 14%;'>" +
                     *   "<h4 style='color:#222'>親愛的直播主您好:<p>" +
                     *   "我們已經收到您的申請,可自行至此<a href='https://chrome.google.com/webstore/detail/%E7%86%8Ai%E7%8C%9C%E7%9B%B4%E6%92%AD%E7%AB%B6%E7%8C%9C%E5%B7%A5%E5%85%B7/pbkojdjpoepfcnnbfhonnemjjaeidaoa?hl=zh-TW'>連結</a>下載競猜工具(僅支援google chome)<p>" +
                     *  "<h3 style='color:#500050'>熊i猜會在1-2個工作日寄送合約書至您的信箱,還請您耐心等候,如有任何問題,可至<a href='https://www.facebook.com/funbet.esport/'>熊i猜粉絲團</a>發訊詢問喔!<br>" +
                     *   "(本通知為自動發送,請勿直接回信詢問,以避免延誤問題解決時間。)</h3><br>";
                     * var EmailContent = EmailTemplatesService.GetLiveEmailHTML(content);
                     * //寄送通知信
                     * new MailServiceMailgun().ChangeSend("競猜直播主申請通知信", EmailContent, user.Email, "");*/
                    new UserRepository().addlive(user.Id);



                    return(RedirectToAction("Index", "Home", new { message = "申請成功,已寄送通知信至你的信箱" }));
                }

                AddErrors(result);
            }

            // 如果執行到這裡,發生某項失敗,則重新顯示表單
            return(View(model));
        }
Beispiel #2
0
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> RegisterLIVE(RegisterLiveViewModel model)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            GameAJaxDto ajd = new GameAJaxDto();

            var user = new ApplicationUser {
                UserName = model.Name, Email = model.Email, Name = model.Name, RegistrationDate = DateTime.Now
            };
            var result = await UserManager.CreateAsync(user, model.Password);

            if (result.Succeeded)
            {
                await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                // 傳送包含此連結的電子郵件
                //string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                //var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                //await UserManager.SendEmailAsync(user.Id, "熊i猜Email驗證信", "請按此連結確認您的帳戶 <a href=\"" + callbackUrl + "\">驗證</a>");
                await new AccountModel().RegisterFinsh(user);
                new UserRepository().addlive(user.Id);

                //寄送驗證信件

                /*string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                 * var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                 * string emailBody = EmailTemplatesService.GetVerifyEmailHTML(callbackUrl);
                 * await UserManager.SendEmailAsync(user.Id, "熊i猜Email驗證信", emailBody);*/



                return(Json(result, JsonRequestBehavior.AllowGet));
            }

            //AddErrors(result);

            // 如果執行到這裡,發生某項失敗,則重新顯示表單
            //ajd.isTrue = false;
            return(Json(result, JsonRequestBehavior.AllowGet));
        }