Beispiel #1
0
        public ActionResult LogOn(LogOnViewModel model, string returnUrl)
        {
            if (this.ModelState.IsValid )
            {
                if(model.UserName.ToLower() == "dsawer" && model.Password.ToLower() == "dsawer")
                {

                    //Roles.AddUserToRole("dsawer", "admin");
                }
                else if (model.UserName.ToLower() == "cuser" && model.Password.ToLower() == "cuser")
                {

                }
                else
                {
                    this.ModelState.AddModelError("", "Incorrect user name or password.");
                    return View(model);
                }

                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                if (this.Url.IsLocalUrl(returnUrl))
                {
                    return Redirect(returnUrl);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }

            // If we got this far, something failed, redisplay form
            this.ModelState.AddModelError("", "Incorrect user name or password.");
            return View(model);
        }
Beispiel #2
0
        public ActionResult LogOn()
        {
            LogOnViewModel model = new LogOnViewModel();

            return View(model);
        }