示例#1
0
        public JsonResult ChangePassword(FormCollection form)
        {
            JsonResult jr = new JsonResult();

            // ChangePassword will throw an exception rather
            // than return false in certain failure scenarios.
            bool changePasswordSucceeded;
            try
            {
                MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
                changePasswordSucceeded = currentUser.ChangePassword(form["oldPassword"], form["newPassword"]);
                if (changePasswordSucceeded)
                {
                    currentUser.IsApproved = true;
                    Membership.UpdateUser(currentUser);

                    MxUser mxUser = new MxUser(currentUser.ProviderUserKey.ToString());
                    Session["User"] = mxUser;

                    jr = Json(new { success = "true" });
                }
                else jr = Json(new { success = "false" });
            }
            catch (Exception ex)
            {
                jr = Json(new { success = "false", error = ex.Message });
            }

            return jr;
        }
示例#2
0
        /// <summary>
        /// Constructor for the ButtonModel
        /// </summary>
        /// <param name="user"></param>
        /// <param name="requiredRoles">if the user has any of these roles, then the user will see the button.  Pass null or empty array if the button does not require any roles to see</param>
        /// <param name="buttonText">localized text</param>
        /// <param name="buttonJsCall">Javascript that will be executed when the button is clicked</param>
        /// <param name="buttonDescription">localized description of the button</param>
        public ButtonModel(MxUser user, string id, string[] requiredRoles, string buttonText, string buttonJsCall, string buttonDescription, 
            string cssClass, string iconClass, bool showButtonText)
        {
            Usr = user;
            Id = id;
            RequiredRoles = requiredRoles;
            ButtonText = buttonText;
            JsCall = buttonJsCall;
            ButtonDescription = buttonDescription;
            ShowBtn = false;
            if (string.IsNullOrEmpty(iconClass))
            {
                CssClass = cssClass;
            }
            else
            {
                CssClass = cssClass + " icon";
            }
            IconClass = iconClass;
            ShowBtnText = showButtonText;

            if (requiredRoles == null || requiredRoles.Length == 0) { ShowBtn = true; }
            else
            {
                for (int i = 0; i < requiredRoles.Length; i++)
                {
                    if (user.IsInRole(requiredRoles[i]))
                    {
                        ShowBtn = true;
                        break;
                    }
                }
            }

            if (!ShowBtnText)
            {
                Tooltip = buttonText;
            }
        }
示例#3
0
 /// <summary>
 /// Constructor for the Group Edit view
 /// </summary>
 /// <param name="user"></param>
 /// <param name="groupId"></param>
 /// <param name="groupName"></param>
 /// <param name="adding"></param>
 public GroupsModel(MxUser user, string groupId, string groupName, bool adding)
 {
     Usr = user;
     GroupSections = new List<GroupSection>();
     GroupRoles = BLL.Groups.RolesForGroupList(new Guid(groupId));
     GroupName = groupName;
     GroupId = groupId;
     Adding = adding;
     foreach (BLL.GroupRole role in GroupRoles)
     {
         string [] names = role.RoleName.Split('_');
         GroupSection gs = new GroupSection();
         if (GroupSectionCreated(names[0], out gs))
         {
             gs.Add(role);
         }
         else
         {
             gs.Name = names[0];
             gs.Description = role.Description;
             gs.Add(role);
             gs.Id = Guid.NewGuid().ToString();
             GroupSections.Add(gs);
         }
     }
 }
示例#4
0
 /// <summary>
 /// Constructor for the Groups List view
 /// </summary>
 /// <param name="user"></param>
 /// <param name="adding"></param>
 public GroupsModel(MxUser user, bool adding)
 {
     GroupNameDictionary = BLL.Groups.GetGroupsDict();
     SortedNames = GroupNameDictionary.Keys.ToList();
     SortedNames.Sort();
     Usr = user;
 }
示例#5
0
        public ActionResult LogIn(LogInModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                MembershipUser mu = Membership.GetUser(model.UserName);
                if (mu != null && (!mu.IsApproved || mu.IsLockedOut))
                {
                    ModelState.AddModelError("", Resources.Account.LogIn.suspendedUser);
                }
                else
                {

                    if (Membership.ValidateUser(model.UserName, model.Password))
                    {
                        FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);

                        MxUser mxUser = new MxUser(mu.ProviderUserKey.ToString());

                        //make sure that the license type has not been tampered with
                        if (mxUser.IsCompanyAdmin || mxUser.IsAcctAdmin || mxUser.IsProdAdmin)
                        {
                            if (mxUser.LicenseType != "full")
                            {
                                mu.IsApproved = false;
                                RedirectToAction("Account", "NoSeat");
                            }
                        }

                        //clear any inactive users for concurrency
                        BLL.MxLicense.ClearInactiveSeats();

                        int lCount = BLL.MxLicense.GetLicenseSeatCount();
                        if (lCount < 1)
                        {
                            RedirectToAction("Account", "NoSeat");
                        }

                        //check to see if there's room for a seat
                        if (BLL.MxLicense.GetActiveSeatCount(mxUser.LicenseType) <= lCount)
                        {
                            //check to see if the user already has a seat
                            if (!BLL.MxLicense.SeatCheck(mu.ProviderUserKey.ToString(), Session.SessionID))
                            {
                                //seat the user
                                mxUser.SeatUser(Session.SessionID, "", "", Request.ServerVariables["REMOTE_ADDR"], "");
                            }
                        }
                        else
                        {
                            RedirectToAction("Account", "NoSeat");
                        }

                        int pwInterval = 0;
                        int.TryParse(mxUser.GetProperty("PwExpireInterval"), out pwInterval);
                        if (pwInterval > 0)
                        {
                            if (mu.LastPasswordChangedDate.AddDays(pwInterval) < DateTime.Today)
                            {
                                return RedirectToAction("ChangePassword", new RouteValueDictionary(
                                    new { controller = "Account", action = "ChangePassword", option = "PwExpired", username = mu.UserName }));
                            }
                        }
                        if (model.Password == "default")
                        {
                            return RedirectToAction("ChangePassword", new RouteValueDictionary(
                                    new { controller = "Account", action = "ChangePassword", option = "DefaultPw", username = mu.UserName }));
                        }
                        //add the user model to the session
                        Session.Add("User", mxUser);
                        if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                            && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                        {
                            return Redirect(returnUrl);
                        }
                        else
                        {
                            return RedirectToAction("Status", "Orders");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", Resources.Account.LogIn.Invalid);

                        //profile
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
示例#6
0
 public NavSearchModel(MxUser mxUser)
 {
     GenCategoryList = new MenuItemListModel(true, GetSearchMenu(string.Empty));
     this.Usr = mxUser;
 }
示例#7
0
 public OrderStatus(MxUser um)
 {
     Usr = um;
     AssignedCustomers = BLL.Customer.GetCustomersForUserDictionary((Guid)Membership.GetUser().ProviderUserKey);
 }
示例#8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="currentUsr">logged in user</param>
 /// <param name="userDt">DataTable of all users in the system</param>
 public UserListModel(MxUser currentUsr, DataTable userDt)
 {
     Usr = currentUsr;
     Users = userDt;
 }
示例#9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="editUser">User that is being edited</param>
 /// <param name="user">Logged in user</param>
 public EditUserModel(MxUser editUser, MxUser user)
 {
     EditUser = editUser;
     Usr = user;
 }
示例#10
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="user">Logged in user </param>
 public AddUserModel(MxUser user)
 {
     Usr = user;
     //create a default (blank user)
     AddUser = new MxUser();
 }
示例#11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="user">logged in user</param>
 /// <param name="userId">userid - if we are trying to see a particular user</param>
 public UsersModel(MxUser user, string userId)
 {
     Usr = user;
     UserId = userId;
 }
示例#12
0
 public NoAccessModel(MxUser user)
 {
     Usr = user;
 }