protected void uvButton_Click(object sender, EventArgs e)
        {
            SRPUser user  = new SRPUser((int)((SRPUser)Session[SessionData.UserProfile.ToString()]).Uid);
            var     valid = SRPUser.VerifyPassword(user.Username, uxCPass.Text);

            if (!valid)
            {
                MasterPage.PageError = String.Format(SRPResources.ApplicationError1, "Your current password is invalid.");
                return;
            }
            user.LastPasswordReset = DateTime.Now;
            user.MustResetPassword = false;
            user.NewPassword       = uxPassword.Text;
            try {
                user.ClearErrorCodes();
                if (user.Update())
                {
                    Session[SessionData.UserProfile.ToString()] = user;
                    MasterPage.PageMessage = String.Format("Password has been changed.");
                }
                else
                {
                    string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                    foreach (BusinessRulesValidationMessage m in user.ErrorCodes)
                    {
                        message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                    }
                    message = string.Format("{0}</ul>", message);
                    MasterPage.PageError = message;
                }
            } catch (Exception ex) {
                MasterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
            }
        }
Esempio n. 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            SRPUser user = (SRPUser)Session[SessionData.UserProfile.ToString()];

            user.NewPassword       = uxNewPasswordField.Text;
            user.MustResetPassword = false;
            user.LastPasswordReset = DateTime.Now;
            user.Update();
            Session[SessionData.UserProfile.ToString()] = user;
            FormsAuthentication.RedirectFromLoginPage(user.Username, false);
        }
        protected void ResetPassword_Click(object sender, EventArgs e)
        {
            Error.Text = string.Empty;
            object userIdObject = Session["UID"];

            int userId = 0;

            if (userIdObject == null ||
                !int.TryParse(userIdObject.ToString(), out userId) ||
                userId == 0)
            {
                Response.Redirect("Default.aspx");
            }

            SRPUser user = SRPUser.Fetch(userId);

            user.NewPassword = uxPassword.Text;
            try {
                user.Update();
                SRPUser currentUser = Session[SessionData.UserProfile.ToString()] as SRPUser;
                var     changeInfo  = new {
                    Changer = currentUser == null
                              ? "unknown"
                              : currentUser.Username,
                    User = user.Username
                };
                this.Log().Info("Admin user {0} changed password for user {1}",
                                changeInfo.Changer,
                                changeInfo.User);
            } catch (Exception ex) {
                this.Log().Error("Admin user unable to change password for user {0}: {1}",
                                 userId,
                                 ex.Message);
                Error.Text = string.Format("An error occurred: {0}", ex.Message);
            }
            Response.Redirect("UserAddEdit.aspx");
        }
Esempio n. 4
0
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Tenant/TenantUserList.aspx";

            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(returnURL);
            }
            if (e.CommandName.ToLower() == "refresh")
            {
                try {
                    odsSRPUser.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    MasterPage.PageMessage = SRPResources.RefreshOK;
                } catch (Exception ex) {
                    MasterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }

            if (e.CommandName.ToLower() == "add" || e.CommandName.ToLower() == "addandback")
            {
                try {
                    SRPUser obj = new SRPUser();


                    obj.Username     = ((TextBox)((DetailsView)sender).FindControl("Username")).Text;
                    obj.NewPassword  = ((TextBox)((DetailsView)sender).FindControl("Password")).Text;
                    obj.FirstName    = ((TextBox)((DetailsView)sender).FindControl("FirstName")).Text;
                    obj.LastName     = ((TextBox)((DetailsView)sender).FindControl("LastName")).Text;
                    obj.EmailAddress = ((TextBox)((DetailsView)sender).FindControl("EmailAddress")).Text;
                    obj.Division     = ((TextBox)((DetailsView)sender).FindControl("Division")).Text;
                    obj.Department   = ((TextBox)((DetailsView)sender).FindControl("Department")).Text;
                    obj.Title        = ((TextBox)((DetailsView)sender).FindControl("Title")).Text;
                    //((TextBox)((DetailsView)sender).FindControl("Password")).Attributes["value"] = obj.Password;

                    obj.IsActive          = true;
                    obj.MustResetPassword = true;
                    obj.IsDeleted         = false;

                    obj.AddedDate   = DateTime.Now;
                    obj.AddedUser   = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A";  // Get from session
                    obj.LastModDate = obj.AddedDate;
                    obj.LastModUser = obj.AddedUser;

                    obj.TenID = int.Parse(Session["ATENID"].ToString());

                    if (obj.IsValid(BusinessRulesValidationMode.INSERT))
                    {
                        obj.Insert();
                        if (e.CommandName.ToLower() == "addandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        lblUID.Text = obj.Uid.ToString();

                        odsSRPUser.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        MasterPage.PageMessage = SRPResources.AddedOK;
                    }
                    else
                    {
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        MasterPage.PageError = message;
                    }
                } catch (Exception ex) {
                    MasterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback")
            {
                try {
                    int     pk  = int.Parse(((DetailsView)sender).Rows[0].Cells[1].Text);
                    SRPUser obj = new SRPUser(pk);


                    obj.Username          = ((TextBox)((DetailsView)sender).FindControl("Username")).Text;
                    obj.NewPassword       = ((TextBox)((DetailsView)sender).FindControl("Password")).Text;
                    obj.FirstName         = ((TextBox)((DetailsView)sender).FindControl("FirstName")).Text;
                    obj.LastName          = ((TextBox)((DetailsView)sender).FindControl("LastName")).Text;
                    obj.EmailAddress      = ((TextBox)((DetailsView)sender).FindControl("EmailAddress")).Text;
                    obj.Division          = ((TextBox)((DetailsView)sender).FindControl("Division")).Text;
                    obj.Department        = ((TextBox)((DetailsView)sender).FindControl("Department")).Text;
                    obj.Title             = ((TextBox)((DetailsView)sender).FindControl("Title")).Text;
                    obj.IsActive          = ((CheckBox)((DetailsView)sender).FindControl("IsActive")).Checked;
                    obj.MustResetPassword = ((CheckBox)((DetailsView)sender).FindControl("MustResetPassword")).Checked;
                    //((TextBox)((DetailsView)sender).FindControl("Password")).Attributes.Add("value", obj.Password);


                    //obj.IsDeleted = ((TextBox)((DetailsView)sender).FindControl("IsDeleted")).Text;
                    //obj.LastPasswordReset = ((TextBox)((DetailsView)sender).FindControl("LastPasswordReset")).Text;
                    //obj.DeletedDate = ((TextBox)((DetailsView)sender).FindControl("DeletedDate")).Text;
                    //obj.LastModDate = ((TextBox)((DetailsView)sender).FindControl("LastModDate")).Text;
                    //obj.LastModUser = ((TextBox)((DetailsView)sender).FindControl("LastModUser")).Text;
                    //obj.AddedDate = ((TextBox)((DetailsView)sender).FindControl("AddedDate")).Text;
                    //obj.AddedUser = ((TextBox)((DetailsView)sender).FindControl("AddedUser")).Text;

                    obj.LastModDate = DateTime.Now;
                    obj.LastModUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session

                    if (obj.IsValid(BusinessRulesValidationMode.UPDATE))
                    {
                        obj.Update();

                        SaveGroups((DetailsView)sender, obj);
                        //SavePermissions((DetailsView)sender, obj);
                        //SaveFolders((DetailsView)sender, obj);

                        if (e.CommandName.ToLower() == "saveandback")
                        {
                            Response.Redirect(returnURL);
                        }
                        odsSRPUser.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        MasterPage.PageMessage = SRPResources.SaveOK;
                    }
                    else
                    {
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        MasterPage.PageError = message;
                    }
                } catch (Exception ex) {
                    MasterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
        }
Esempio n. 5
0
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/";

            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(returnURL);
            }
            if (e.CommandName.ToLower() == "password")
            {
                Response.Redirect("~/ControlRoom/Modules/PortalUser/PasswordReset.aspx");
            }
            if (e.CommandName.ToLower() == "refresh")
            {
                try
                {
                    odsCMSUser.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    //ICMSMasterPage masterPage = (ICMSMasterPage)Master;
                    //masterPage.
                    PageMessage = SRPResources.RefreshOK;
                }
                catch (Exception ex)
                {
                    //ICMSMasterPage masterPage = (ICMSMasterPage)Master;
                    //masterPage.
                    PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }


            if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback")
            {
                try
                {
                    SRPUser obj = new SRPUser();
                    int     pk  = (int)SRPUser.Uid;
                    obj = SRPUser.Fetch(pk);

                    obj.FirstName    = ((TextBox)((DetailsView)sender).FindControl("FirstName")).Text;
                    obj.LastName     = ((TextBox)((DetailsView)sender).FindControl("Lastname")).Text;
                    obj.LastName     = ((TextBox)((DetailsView)sender).FindControl("Lastname")).Text;
                    obj.EmailAddress = ((TextBox)((DetailsView)sender).FindControl("Emailaddress")).Text;
                    obj.Title        = ((TextBox)((DetailsView)sender).FindControl("Title")).Text;
                    obj.Department   = ((TextBox)((DetailsView)sender).FindControl("Department")).Text;
                    obj.Division     = ((TextBox)((DetailsView)sender).FindControl("Division")).Text;
                    obj.LastModDate  = DateTime.Now;
                    obj.LastModUser  = "******";     // Get from session

                    if (obj.IsValid(BusinessRulesValidationMode.UPDATE))
                    {
                        obj.Update();
                        SRPUser = obj;
                        Session[SessionData.UserProfile.ToString()] = obj;

                        if (e.CommandName.ToLower() == "saveandback")
                        {
                            Response.Redirect(returnURL);
                        }
                        odsCMSUser.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        //ICMSMasterPage masterPage = (ICMSMasterPage)Master;
                        //masterPage.
                        PageMessage = SRPResources.SaveOK;
                    }
                    else
                    {
                        //ICMSMasterPage masterPage = (ICMSMasterPage)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        //masterPage.
                        PageError = message;
                    }
                }
                catch (Exception ex)
                {
                    //ICMSMasterPage masterPage = (ICMSMasterPage)Master;
                    //masterPage.
                    PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
        }