public ActionResult SignIn(SignInInput input) { if (!ModelState.IsValid) { input.Password = null; input.Login = null; return(View(input)); } var user = us.Get(input.Login, input.Password); //ACHTUNG: remove this line in a real app if (user == null && input.Login == "o" && input.Password == "1") { user = new User { Login = "******", Roles = new[] { new Role { Name = "admin" } } } } ; if (user == null) { ModelState.AddModelError("", "Try Login: o and Password: 1"); return(View()); } formsAuth.SignIn(user.Login, input.Remember, user.Roles.Select(o => o.Name)); return(RedirectToAction("index", "home")); }
public ActionResult LogIn(LoginModel model, string returnUrl) { try { var md5Pwd = IMS_UP_YH.GetPwdMD5(model.Password); if (membership.ValidateUser(model.UserID, md5Pwd)) { formAuth.SignIn(model.UserID, false); string url = RedirectToLocal(returnUrl); return(this.JsonFormat(new ExtResult { success = true, msg = url })); } return(this.JsonFormat(new ExtResult { success = false, msg = "提供的用户名或密码不正确" })); } catch (Exception ex) { return(this.JsonFormat(new ExtResult { success = false, msg = ex.Message })); } }
public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl) { if (!ValidateLogOn(userName, password)) { return(View()); } _formsAuthentication.SignIn(userName, rememberMe); if (!String.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult Authenticate() { /* * The salt passed to the method below can by dynamic, so you can include * some extra information like id, etc... something that you usually add * into hidden input. */ ValidateAntiForgeryToken(AntiForgeryTokenSaltNames.Login /*, Request.Form["id"], RouteData.Values["id"] as string */); if (User.Identity.IsAuthenticated) { return(Ajax(RedirectToAction("index", "home"))); } var viewData = new LogonViewData(); if (!TryUpdateModel(viewData) | !TryUpdateModel(viewData.Details) | !validationService.Validate(viewData) || !captchaValidator.Validate() || !membershipService.ValidateUser(viewData.Details)) { ModelState.ResetModelValue("TuringNumber"); return(AlternatePartialView(viewData)); } formsAuthentication.SignIn( viewData.Details.UserName, viewData.RememberMe, Guid.NewGuid().Shrink() /* * You can read this value using formsAuthentication.UserData() * at any place of the authenticated request */); if (!String.IsNullOrEmpty(viewData.ReturnUrl)) { return(Redirect(viewData.ReturnUrl)); } return(Ajax(RedirectToAction("index", "home"))); }
public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl) { UserModel user = null; if (!ValidateLogOn(userName, password, out user)) { return(View()); } string loginSession = RedisHelper.GetLoginSession(user.UserName + ":session", Util.GetRootedUri("").ToString()); if (!string.IsNullOrEmpty(loginSession) && !string.Equals(loginSession, Session.SessionID, StringComparison.Ordinal)) { Session["_askuser_"] = true; Session["_tempuser_"] = user.UserName; Session["_remember_"] = rememberMe; //转跳 到询问页面 return(this.RedirectToAction("askuser", "openid")); } _formsAuthService.SignIn(user, rememberMe); string claimIdentifier = Util.GetUserClaimIdentifier(userName).ToString(); _logService.Add(new LoginLogModel { ID = Guid.NewGuid(), AddTime = DateTime.Now, Flag = 0, UserName = user.UserName, OpenIdClaimedIdentifier = claimIdentifier, OpenIdFriendlyIdentifier = claimIdentifier }); if (string.IsNullOrEmpty(returnUrl)) { return(RedirectToAction("Index", "Home")); } return(Redirect(returnUrl)); }
public ActionResult SignIn(SignInInput input) { if (!ModelState.IsValid) { input.Password = null; input.Login = null; return(View(input)); } var user = us.Get(input.Login, input.Password); if (user == null) { ModelState.AddModelError("", "Try Login: o and Password: 1"); // ModelState.AddModelError(Mui.Security, Mui.Invalid_Username_or_Password); return(View()); } Session["userId"] = user.Id; formsAuth.SignIn(user.Login, input.Remember, user.Roles.Select(o => o.Name)); var list = bi.Where(o => o.UserId.Equals(user.Id)).SingleOrDefault(); if (list == null) { if (user.UserTypeId == 2) { return(RedirectToAction("CreateBilling", "UserBillingInformation")); } else { return(RedirectToAction("index", "Application")); } } else { if (user.UserTypeId == 1) { return(RedirectToAction("index", "Home")); } else if (user.UserTypeId == 2) { return(RedirectToAction("index", "Application")); } else { return(RedirectToAction("index", "Home")); } } }
public ActionResult Login(LoginViewModel loginviewmodel, string returnUrl) { if (ModelState.IsValid) { //ToDo : Encrypt the password before sending the password string password = CryptUtils.GetPasswordEncrypted(loginviewmodel.Password); if (provider.ValidateUser(loginviewmodel.UserName, password)) { FormsAuth.SignIn(loginviewmodel.UserName, false); return(RedirectToLocal(returnUrl)); } ModelState.AddModelError("", "The user name or password provided is incorrect."); ViewBag.ErrorMessage = "The user name or password provided is incorrect."; } return(View("LoginFlat", loginviewmodel)); }
public void LogonAction_Post_Returns_View() { //arrange _formsAuth.SignIn("userName", false); _membershipService.ValidateUser("userName", "password").Returns(true); //Act var controller = new AccountController(_formsAuth, _membershipService); var view = controller.LogOn("userName", "password", false, string.Empty); //Assert view.AssertActionRedirect(); }
public ActionResult LoginIn(SignInInput input, string returnUrl) { if (!ModelState.IsValid) { input.Password = null; return(View(input)); } var user = userService.Get(input.UserName, input.Password); if (user == null) { ModelState.AddModelError("", "用户名或密码不正确"); return(View(input)); } formsAuth.SignIn(user.UserName, input.RememberMe, user.Roles.Select(x => x.Name)); return(RedirectToLocal(returnUrl)); }
public ActionResult SignIn(SignInInput input) { if (!ModelState.IsValid) { input.Password = null; input.Name = null; return(View(input)); } if (!userService.Validate(input.Name, input.Password)) { SetError("Numele sau parola nu sunt introduse corect, va rugam sa mai incercati o data"); return(View()); } var roles = userService.GetRoles(userService.Get(input.Name).Id); formsAuth.SignIn(input.Name, false, roles); return(RedirectToAction("Index", "Home")); }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { User user; try { user = _accountService.Get(model.UserName, model.Password); } catch (Exception ex) { ModelState.AddModelError("", "Some proplem in validating your login. Please try again later."); return(View()); } if (user == null) { ModelState.AddModelError("", "The user name or password provided is incorrect."); return(View()); } _formsAuth.SignIn(user.Login, model.RememberMe, user.Roles.Select(o => o.Name)); HttpContext.Session["dummy"] = String.Empty; if (returnUrl != null) { return(Redirect(returnUrl)); } else { return(Redirect("/Menu/Index")); } } ModelState.AddModelError("", "The user name or password provided is incorrect."); return(View(model)); }
public ActionResult Login(LoginViewModel model, string returnUrl) { User user; if (ModelState.IsValid) { user = _userService.GetUser(model.UserName, model.Password); if (user != null) { _formsAuth.SignIn(user.UserName, model.RememberMe, new List <string>() { "none" }); return(RedirectToAction("index", "posts")); } ModelState.AddModelError("", "The user name or password provided is incorrect"); return(View(model)); } ModelState.AddModelError("", "The user name or password provided is incorrect"); return(View(model)); }