BurningPlage.Controllers.AccountController.Login C# (CSharp) Метод

Login() публичный Метод

public Login ( string username, string password, bool rememberMe ) : System.Web.Mvc.ActionResult
username string
password string
rememberMe bool
Результат System.Web.Mvc.ActionResult
        public ActionResult Login(string username, string password, bool? rememberMe)
        {
            ViewData["Title"] = "Login";

            // Non-POST requests should just display the Login form
            if (Request.HttpMethod != "POST")
            {
                return View();
            }

            // Basic parameter validation
            List<string> errors = new List<string>();

            if (String.IsNullOrEmpty(username))
            {
                errors.Add("You must specify a username.");
            }

            if (errors.Count == 0)
            {

                // Attempt to login
                bool loginSuccessful = Provider.ValidateUser(username, password);

                if (loginSuccessful)
                {

                    FormsAuth.SetAuthCookie(username, rememberMe ?? false);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    errors.Add("The username or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            ViewData["errors"] = errors;
            ViewData["username"] = username;
            return View();
        }