public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            var clientIP = Request.UserHostAddress.ToString();

            if (!IPCount.CheckIsAble(clientIP))
            {
                ModelState.AddModelError("UserName", "已经超过尝试次数");
            }
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.UserName);

                if (user == null)
                {
                    // 请不要显示该用户不存在或者未经确认
                    ModelState.AddModelError("", "用户不存在!");
                }
                else
                {
                    var useremail = user.Email.Substring(0, 2) + "***" + user.Email.Substring(user.Email.IndexOf('@'));
                    //身份验证
                    var preVerify4ResetPasswordModel = new PreVerify4ResetPasswordModel {
                        UserName = user.UserName,
                        Email    = useremail
                    };
                    return(View("Verify4ResetPassword", preVerify4ResetPasswordModel));//跳转到身份认证
                }
                //var result4VerifyCode =
                // await PhoneVerifyCodeProvider.CodeVerify(user.PhoneNumber, model.VerifyCode, TimeSpan.Zero);

                //if (!result4VerifyCode.Success)//验证码验证
                //{
                //    ModelState.AddModelError("VerifyCode", "验证码错误!");
                //}

                //var aa = await UserManager.PasswordValidator.ValidateAsync(model.Password);
                //if (!aa.Succeeded)
                //{
                //    foreach (var error in aa.Errors)
                //    {
                //        ModelState.AddModelError("", error);
                //    }
                //}

                //if (!ModelState.IsValid)
                //{
                //    return View(model);
                //}

                //await UserManager.RemovePasswordAsync(user.Id);

                //await UserManager.AddPasswordAsync(user.Id, model.Password);

                //return RedirectToAction("ForgotPasswordConfirmation", "Account");
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(View(model));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            var clientIP = Request.UserHostAddress.ToString();

            if (!IPCount.CheckIsAble(clientIP))
            {
                ModelState.AddModelError("UserName", "已经超过尝试次数");
            }
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = new SysUser {
                UserName = model.UserName, Email = CommonCodeGenerator.GenerateEmail(model.UserName),
            };

            var result = await UserManager.CreateAsync(user, model.Password);

            if (result.Succeeded)
            {
                var iUnitOfWork = DependencyResolver.Current.GetService <IUnitOfWork>();
                if (!string.IsNullOrEmpty(model.DepartmentId))
                {
                    SysDepartmentSysUserService.Save(null,
                                                     new SysDepartmentSysUser {
                        SysDepartmentId = model.DepartmentId, SysUserId = user.Id
                    });
                }
                //前三个用户赋予管理员权限

                if (UserManager.Users.Count() < 3)
                {
                    await UserManager.AddToRoleAsync(user.Id, "系统管理员");
                }
                else
                {
                    await UserManager.AddToRoleAsync(user.Id, "运动员");
                }
                await iUnitOfWork.CommitAsync();

                TempData[Alerts.Success] = "注册成功,请您登陆";

                //await SignInManager.SignInAsync(user, false, true);

                // 有关如何启用帐户确认和密码重置的详细信息,请访问 http://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, "确认你的帐户", "请通过单击 <a href=\"" + callbackUrl + "\">这里</a>来确认你的帐户");

                return(RedirectToAction("Index", "Index", new { area = "Platform" }));
            }
            AddErrors(result);


            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(View(model));
        }