コード例 #1
0
		public async Task<ActionResult> JsonLogin(LoginModel model, string returnUrl)
		{
			if (ModelState.IsValid)
			{
				var accountService = new AccountService();
				var success = await accountService.Login(model.UserName, model.Password);

				if (success)
				{
					FormsAuthentication.SetAuthCookie(model.UserName, false);
				}
			
				return RedirectToAction("Index", "Home");
			}

			return View(model);
		}
コード例 #2
0
		public async Task<ActionResult> Login(LoginModel model, string returnUrl)
		{
			if (ModelState.IsValid)
			{
				var accountService = new AccountService();
				var success = await accountService.Login(model.UserName, model.Password);
				if (success)
				{
					FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);					
					return RedirectToAction("Index", "Home");
				}
				
			}

			// If we got this far, something failed, redisplay form
			ModelState.AddModelError("", "The user name or password provided is incorrect.");
			return View(model);
		}