public JsonResult Register(Credentials credentials) { if (!ModelState.IsValid) { return(ControllerExtensions.CreateModelValidationResult(this)); } var context = invoker.Invoke(new InvokerContext(new UserRegistration(), credentials)); if (!context.Results.UserRegistered) { return(ControllerExtensions.CreateModelErrors(this, context.Messages.ToArray())); } TempData["Messages"] = context.Messages; return(Json(new { Success = true, RedirectURL = Url.Action("Index") })); }
public JsonResult Login(Credentials credentials) { if (!ModelState.IsValid) { return(ControllerExtensions.CreateModelValidationResult(this)); } var context = invoker.Invoke(new InvokerContext(new UserLogin(), credentials)); if (!context.Results.LoggedIn) { return(ControllerExtensions.CreateModelErrors(this, context.Messages.ToArray())); } TempData["Messages"] = context.Messages; FormsAuthentication.SetAuthCookie(credentials.CompanyName, false); Session["CompanyName"] = credentials.CompanyName; return(Json(new { Success = true, RedirectURL = Url.Action("Index", "Home") })); }