public ActionResult LogOn(LogOnModel model) { string captcha = AccountUtil.GetCaptcha(); if (!captcha.Equals(model.ConfirmationCode, StringComparison.OrdinalIgnoreCase)) { ModelState.AddModelError(string.Empty, "驗證碼錯誤"); } else { if (model.ValidateUser()) { return !String.IsNullOrWhiteSpace(model.RtnUrl) ? (ActionResult)Redirect(model.RtnUrl) : RedirectToAction("Index", "Admin", new { RtnUrl = HttpContext.Request["RtnUrl"] }); } else { ModelState.AddModelError(string.Empty, "帳號密碼錯誤"); } } return View(model); }
/// <summary> /// 測試用快速登入 /// </summary> /// <returns></returns> public virtual ActionResult TestLogon() { LogOnModel model = new LogOnModel() { Account = "admin", Password = "******", ConfirmationCode = AccountUtil.GetCaptcha() }; if (model.ValidateUser()) { return !String.IsNullOrWhiteSpace(model.RtnUrl) ? (ActionResult)Redirect(model.RtnUrl) : RedirectToAction("Index", "Admin", new { RtnUrl = HttpContext.Request["RtnUrl"] }); } else { ModelState.AddModelError(string.Empty, "帳號密碼錯誤"); } return View("LogOn"); }