Ejemplo n.º 1
0
        public ActionResult Register(RegisterModel model)
        {
            if (Utilities.IsSpamIP(Request.UserHostAddress))
            {
                // they are a duplicate IP and are no being referred by an existing user
                ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + Messages.Account);
                return View(model);
            }

            // ignore old browsers and duplicate IPs
            if
                (
                Request.Browser.Type == "IE3" ||
                Request.Browser.Type == "IE4" ||
                Request.Browser.Type == "IE5" ||
                Request.Browser.Type == "IE6" ||
                Request.Browser.Type == "IE7" ||
                BlackIPs.IsIPBlocked(Request.UserHostAddress)

                )
            {
                Response.Redirect("http://browsehappy.com/");
                return View();
            }
            else if (!BootBaronLib.Configs.GeneralConfigs.EnableSameIP &&
                UserAccount.IsAccountIPTaken(Request.UserHostAddress) &&
                string.IsNullOrEmpty(model.RefUser))
            {
                // they are a duplicate IP and are no being referred by an existing user
                ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + Messages.Account);
                return View(model);
            }

            TryUpdateModel(model);

            if (ModelState.IsValid)
            {
                if (!Utilities.IsEmail(model.Email))
                {
                    ModelState.AddModelError("", BootBaronLib.Resources.Messages.IncorrectFormat + ": " + BootBaronLib.Resources.Messages.EMail);
                    return View();
                }
                else if (
                    model.UserName.Trim().Contains(" ") ||
                    model.UserName.Trim().Contains("?") ||
                    model.UserName.Trim().Contains("*") ||
                    model.UserName.Trim().Contains(":") ||
                    model.UserName.Trim().Contains("/") ||
                    model.UserName.Trim().Contains(@"\"))
                {
                    ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + BootBaronLib.Resources.Messages.UserName);
                    return View();
                }
                else if (model.YouAreID == null)
                {
                    ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + BootBaronLib.Resources.Messages.YouAre);
                    return View();
                }

                DateTime dt = new DateTime();

                if (!DateTime.TryParse(model.Year
                                + "-" + model.Month + "-" + model.Day, out dt))
                {
                    ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + BootBaronLib.Resources.Messages.BirthDate);
                    return View();
                }
                else if (DateTime.TryParse(model.Year
                    + "-" + model.Month + "-" + model.Day, out dt))
                {
                    if (Utilities.CalculateAge(dt) < BootBaronLib.Configs.GeneralConfigs.MinimumAge)
                    {
                        ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + BootBaronLib.Resources.Messages.BirthDate);
                        return View();
                    }
                }

                model.UserName = model.UserName.Replace(" ", string.Empty).Replace(":", string.Empty) /* still annoying errors */;

                // Attempt to register the user
                MembershipCreateStatus createStatus;

                Membership.CreateUser(model.UserName, model.NewPassword, model.Email, "Q", "A", true, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.RedirectFromLoginPage(model.UserName, true);

                    UserAccount ua = new UserAccount(model.UserName);
                    uad = new UserAccountDetail();
                    uad.UserAccountID = ua.UserAccountID;

                    uad.BirthDate = dt;
                    uad.YouAreID = model.YouAreID;
                    uad.DisplayAge = true;
                    uad.DefaultLanguage = Utilities.GetCurrentLanguageCode();

                    if (!string.IsNullOrEmpty(model.RefUser))
                    {
                        UserAccount refUser = new UserAccount(model.RefUser);
                        uad.ReferringUserID = refUser.UserAccountID;
                    }

                    uad.Set();

                    StringBuilder sb = new StringBuilder(100);

                    sb.Append(Messages.Hello);
                    sb.Append(Environment.NewLine);
                    sb.Append(Messages.YourNewAccountIsReadyForUse);
                    sb.Append(Environment.NewLine);
                    sb.Append(Environment.NewLine);
                    sb.Append(Messages.UserName + ": ");
                    sb.Append(ua.UserName);
                    sb.Append(Environment.NewLine);
                    sb.Append(Messages.Password + ": ");
                    sb.Append(model.NewPassword);
                    sb.Append(Environment.NewLine);
                    sb.Append(BootBaronLib.Configs.GeneralConfigs.SiteDomain);

                    Utilities.SendMail(ua.EMail, Messages.YourNewAccountIsReadyForUse, sb.ToString());

                    // see if this is the 1st user
                    UserAccounts recentUsers = new UserAccounts();
                    recentUsers.GetNewestUsers();

                    if (recentUsers.Count == 1)
                    {
                        Role adminRole = new Role(SiteEnums.RoleTypes.admin.ToString());

                        UserAccountRole.AddUserToRole(ua.UserAccountID, adminRole.RoleID);
                    }

                    return RedirectToAction("editprofile", "Account");
                }
                else
                {
                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                }
            }

            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult UpdateRoles(int userAccountID, string[] roleOption)
        {
            UserAccount ua = new UserAccount(userAccountID);

            // delete all their roles
            UserAccountRole.DeleteUserRoles(userAccountID);

            foreach (string newRole in roleOption)
            {
               Role thenewRole = new Role(newRole);

               UserAccountRole.AddUserToRole(userAccountID, thenewRole.RoleID);
            }

            if (ua.UserAccountID > 0)
            {
                ViewBag.SelectedUser = ua;
                UserAccountDetail uad = new UserAccountDetail();
                uad.GetUserAccountDeailForUser(ua.UserAccountID);
                ViewBag.UserAccountDetail = uad;
            }

            LoadAllRoles();

            return View("UserManagement");
        }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            InterestIdentityViewBags();

            FindUsersModel model = new FindUsersModel();

            LoadFilteredUsers(false, model);

            ViewBag.FilteredUsers = uas.ToUnorderdList;

            // random
            Role rle = new Role(SiteEnums.RoleTypes.cyber_girl.ToString());

            UserAccounts girlModels = UserAccountRole.GetUsersInRole(rle.RoleID);

            if (girlModels!= null && girlModels.Count > 0)
            {
                BootBaronLib.Operational.StaticHelper.Shuffle(girlModels);

                UserAccount featuredModel = girlModels[0];

                UserAccountDetail featuredPhoto = new UserAccountDetail();
                featuredPhoto.GetUserAccountDeailForUser(featuredModel.UserAccountID);

                int photoNumber = Utilities.RandomNumber(1, 4);

                string photoPath = featuredPhoto.FullProfilePicURL;

                if (photoNumber > 1)
                {
                    UserPhotos ups = new UserPhotos();

                    ups.GetUserPhotos(featuredModel.UserAccountID);

                    if (ups.Count > 0)
                    {
                        foreach (UserPhoto up1 in ups)
                        {
                            if ((up1.RankOrder + 1) == photoNumber)
                            {
                                photoPath = up1.FullProfilePicURL;
                                break;
                            }
                        }
                    }
                }

                // random border color with random user pic from their 3 photos
                string[] colorBorder = BootBaronLib.Configs.GeneralConfigs.RandomColors.Split(',');

                Random rnd=new Random();
                string[] myRandomArray = colorBorder.OrderBy(x => rnd.Next()).ToArray();

                ViewBag.FeaturedModel = string.Format(@"
            <a class=""m_over"" href=""{1}"">
            <img src=""{0}"" class=""featured_user"" style="" border: 2px dashed {2}; "" /></a>", photoPath,
            featuredModel.UrlTo.ToString(), myRandomArray[0]);
            }

            return View(model);
        }
Ejemplo n.º 4
0
        public override string[] GetUsersInRole(string roleName)
        {
            Role rle = new Role(roleName);

            ArrayList allRoles = new ArrayList();

            UserAccounts uas = UserAccountRole.GetUsersInRole(rle.RoleID);

            foreach (UserAccount ua1 in uas) allRoles.Add(ua1.UserName);

            string[] stringArray = (string[])allRoles.ToArray(typeof(string));

            return stringArray;
        }