public virtual ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (MembershipService.ValidateUser(model.Login, model.Password)) { var context = ModelFactory.GetUnitOfWork(); var mRepo = ModelFactory.GetRepository<IMemberRepository>(context); var member = mRepo.GetMember(model.Login); var userData = member.GetUserData(); FormsService.SignIn(model.Login, userData, /*model.RememberMe*/true, ControllerContext.HttpContext.Response); if (!String.IsNullOrEmpty(returnUrl) && !returnUrl.Contains("returnUrl")) { return Redirect(returnUrl); } else { return RedirectToAction(MVC.Mobile.Home.Index()); } } else { ModelState.AddModelError("", Worki.Resources.Validation.ValidationString.MailOrPasswordNotCorrect); } } // Si nous sommes arrivés là, quelque chose a échoué, réafficher le formulaire return View(model); }
public virtual ActionResult LogOn(LogOnModel model) { if (ModelState.IsValid) { try { if (_MembershipService.ValidateUser(model.Login, model.Password)) { var context = ModelFactory.GetUnitOfWork(); var mRepo = ModelFactory.GetRepository<IMemberRepository>(context); var member = mRepo.GetMember(model.Login); var userData = member.GetUserData(); _FormsService.SignIn(model.Login, userData, /*model.RememberMe*/true, ControllerContext.HttpContext.Response); return Json(Url.RequestContext.HttpContext.Request.UrlReferrer); } else { ModelState.AddModelError("", Worki.Resources.Validation.ValidationString.MailOrPasswordNotCorrect); } } catch (Member.ValidationException ex) { _Logger.Error("LogOn", ex); ModelState.AddModelError("", ex.Message); } catch (Exception ex) { _Logger.Error("LogOn", ex); ModelState.AddModelError("", Worki.Resources.Validation.ValidationString.MailOrPasswordNotCorrect); } } throw new ModelStateException(ModelState); }
public virtual ActionResult Login(LogOnModel model) { if (ModelState.IsValid) { try { _MembershipService.ValidateUser(model.Login, model.Password); return new ObjectResult<AuthJson>(ModelHelper.GetAuthData(_MembershipService, model.Login)); } catch (Exception ex) { return new ObjectResult<AuthJson>(null, 400, ex.Message); } } else { return new ObjectResult<AuthJson>(null, 400, ModelState.GetErrors()); } }
public VisitorFormViewModel() { Visitor = new Visitor(); LogOn = new LogOnModel(); }