예제 #1
0
        /// <summary>
        /// Handles the Click event of the cmdUpdate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void CmdUpdateClick(object sender, EventArgs e)
        {
            try
            {
                GetMembershipData(UserId);

                var user = (CustomMembershipUser)MembershipData;

                if (user != null)
                {
                    //user.IsApproved = Authorized.Checked;
                    user.Email       = Email.Text;
                    user.DisplayName = DisplayName.Text;
                    user.FirstName   = FirstName.Text;
                    user.LastName    = LastName.Text;
                    UserManager.UpdateUser(user);
                    OnAction(new ActionEventArgs {
                        Trigger = ActionTriggers.Save
                    });
                }
                ActionMessage.ShowSuccessMessage(GetLocalResourceObject("UpdateUserMessage").ToString());
            }
            catch
            {
                ActionMessage.ShowErrorMessage(LoggingManager.GetErrorMessageResource("UpdateUserError"));
            }
        }
예제 #2
0
        /// <summary>
        /// Handles the Click event of the cmdChangePassword control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void CmdChangePasswordClick(object sender, EventArgs e)
        {
            if (!cvPasswords.IsValid)
            {
                return;
            }

            GetMembershipData(UserId);

            if (MembershipData == null)
            {
                return;
            }

            try
            {
                MembershipData.ChangePassword(MembershipData.ResetPassword(), NewPassword.Text);
                ActionMessage.ShowSuccessMessage(GetLocalResourceObject("PasswordChangeSuccess").ToString());
                GetMembershipData(UserId);
                DataBind();
            }
            catch (Exception ex)
            {
                if (Log.IsErrorEnabled)
                {
                    if (HttpContext.Current.User != null && HttpContext.Current.User.Identity.IsAuthenticated)
                    {
                        MDC.Set("user", HttpContext.Current.User.Identity.Name);
                    }

                    Log.Error(LoggingManager.GetErrorMessageResource("PasswordChangeError"), ex);
                }
                ActionMessage.ShowErrorMessage(LoggingManager.GetErrorMessageResource("PasswordChangeError"));
            }
        }
예제 #3
0
 /// <summary>
 /// Handles the Click event of the UnAuthorizeUser control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void UnAuthorizeUserClick(object sender, EventArgs e)
 {
     try
     {
         AuthorizeUser(false);
         ActionMessage.ShowSuccessMessage(GetLocalResourceObject("UserUnAuthorizedMessage").ToString());
     }
     catch
     {
         ActionMessage.ShowErrorMessage(GetLocalResourceObject("UserUnAuthorizedError").ToString());
     }
 }
예제 #4
0
        /// <summary>
        /// Handles the Click event of the UnLockUser control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void UnLockUserClick(object sender, EventArgs e)
        {
            GetMembershipData(UserId);

            if (MembershipData != null)
            {
                try
                {
                    MembershipData.UnlockUser();
                    ActionMessage.ShowSuccessMessage(GetLocalResourceObject("UpdateUserMessage").ToString());
                    BindData();
                }
                catch
                {
                    ActionMessage.ShowErrorMessage(LoggingManager.GetErrorMessageResource("UpdateUserError"));
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Updates the roles from list.
        /// </summary>
        private void UpdateRolesFromList()
        {
            GetMembershipData(UserId);

            var userName = MembershipData.UserName;

            foreach (ListItem roleListItem in RoleList.Items)
            {
                var roleName   = roleListItem.Text;
                var enableRole = roleListItem.Selected;

                if (enableRole && !UserManager.IsInRole(userName, dropProjects.SelectedValue, roleName))
                {
                    RoleManager.AddUser(userName, Convert.ToInt32(roleListItem.Value));
                }
                else if (!enableRole && UserManager.IsInRole(userName, dropProjects.SelectedValue, roleName))
                {
                    RoleManager.RemoveUser(userName, Convert.ToInt32(roleListItem.Value));
                }
            }

            ActionMessage.ShowSuccessMessage(GetLocalResourceObject("UserRolesUpdateSuccess").ToString());
        }
예제 #6
0
        /// <summary>
        /// Handles the Click event of the cmdUpdate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void CmdUpdateClick(object sender, EventArgs e)
        {
            try
            {
                GetMembershipData(UserId);

                if (MembershipData != null)
                {
                    var profile = new WebProfile().GetProfile(MembershipData.UserName);
                    profile.DisplayName = DisplayName.Text;
                    profile.FirstName   = FirstName.Text;
                    profile.LastName    = LastName.Text;

                    ActionMessage.ShowSuccessMessage(GetLocalResourceObject("UpdateProfile").ToString());
                    OnAction(new ActionEventArgs {
                        Trigger = ActionTriggers.Save
                    });
                }
            }
            catch
            {
                ActionMessage.ShowErrorMessage(LoggingManager.GetErrorMessageResource("ProfileUpdateError"));
            }
        }