public ActionResult Login(LoginVM LVM, string returnURL) { AppBL userLogin = new AppBL(); if (userLogin.isValidUser(LVM.Username, LVM.Password)) { FormsAuthentication.SetAuthCookie(LVM.Username, false); return(RedirectToAction(returnURL)); } ModelState.AddModelError("CredentialError", "Niepoprawna nazwa lub hasło użytkownika"); return(View("Login")); }
public ActionResult Login(LoginVM vm) { if (ModelState.IsValid) { AppBL appBL = new AppBL(); if (appBL.isValidUser(vm)) { FormsAuthentication.SetAuthCookie(vm.username, false); return(Redirect("/Users/Index")); } ModelState.AddModelError("CredentialError", "Niepoprawna nazwa użytkownika lub hasło"); } return(View(vm)); }
public ActionResult Logowanie(LogowanieVM vm, string ReturnUrl) { FormsAuthentication.SignOut(); AppBL appBL = new AppBL(); if (appBL.isValidAutoryzacja(vm.login, vm.haslo, vm.typUzytkownika)) { appBL.Zaloguj(vm); TempData["Informacja"] = "Witaj na stronie " + vm.login; return(ReturnUrl != null?Redirect(ReturnUrl) : Redirect("Index")); } ModelState.AddModelError("Informacja", "Niepoprawna nazwa użytkownika lub hasło"); return(View(vm)); }
public ActionResult NewUser(LoginVM newUser) { if (ModelState.IsValid) { AppBL appBL = new AppBL(); if (!(ViewBag.availability = appBL.isUserNameAvailable(newUser.username))) { return(View(newUser)); } newUser.password = newUser.hashPassword(); db.adminsDB.Add(newUser); db.SaveChanges(); return(RedirectToAction("Login")); } return(View(newUser)); }