public ActionResult Register(RegisterViewModel model) { if (ModelState.IsValid) { var db = GetDataBaseName(model.Email); var newUser = new User { Email = model.Email, Password = model.Password }; UserModel.Init(db); Guid userId = UserModel.Register(newUser); if (userId != null) { ControllerContext.HttpContext.Session.Add("UserId", userId); FormsAuth.Login(model.Email); //FormsAuthentication.SetAuthCookie(model.Email, false); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Registration is not successful"); } } return(View(model)); }
/// <summary> /// Initializes a new instance of the <see cref="OrderingTestSettings" /> class. /// </summary> /// <param name="locale">The locale.</param> /// <param name="distributor">The distributor.</param> public OrderingTestSettings(string locale, string distributor) { this.Locale = locale; this.Distributor = distributor; // Setting the current culture. Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(locale); //var membershipUser = (Membership.GetUser(distributor, true)) as MembershipUser<DistributorProfileModel>; FormsAuth v = new FormsAuth(); v.Login(distributor); }
public ActionResult LogIn(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var db = GetDataBaseName(model.Email); var user = UserModel.Init(db).Validate(model.Email, model.Password); if (user != null) { System.Web.HttpContext.Current.Session.Add("UserId", user.Id); FormsAuth.Login(model.Email); //FormsAuthentication.SetAuthCookie(model.Email, false); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "The email or password provided is incorrect."); } return(View()); }