Exemple #1
0
        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));
        }
Exemple #2
0
        /// <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);
        }
Exemple #3
0
        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());
        }