public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { UserManager userManager = new UserManager(); if (userManager.LogOnLoginAndPassExist(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", "Błędne dane"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user MembershipCreateStatus createStatus; Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); if (createStatus == MembershipCreateStatus.Success) { UserManager userManager = new UserManager(); if (!userManager.IsLoginExist(model.UserName)) { userManager.Add(model); FormsAuthentication.SetAuthCookie(model.UserName, false); return RedirectToAction("Welcome", "Home"); } else { // Taki nick istnieje - not implements } } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } } // If we got this far, something failed, redisplay form return View(model); }