Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                //Remove validation for Windows users
                if (HttpContext.Current != null && Context.User is WindowsPrincipal)
                {
                    ValidEmail.Visible = false;
                    EmailLabel.TextKey = "WINDOWS_USER_NAME";
                    EmailLabel.Text    = "Windows User Name";
                }

                // TODO: Jonathan - need to bring in country functionality from esperantus or new somehow?
                BindCountry();

                // TODO: Fix this
                // More esperanuts country stuff...
                // CountryInfo country = CountryInfo.CurrentCountry;
                //if (country != null && CountryField.Items.FindByValue(country.Name) != null)
                //	CountryField.Items.FindByValue(country.Name).Selected = true;
                BindState();


                // Edit check
                if (EditMode)   // Someone requested edit this record
                {
                    //True is use is editing himself, false if is edited by an admin
                    selfEdit = (userName == PortalSettings.CurrentUser.Identity.UserName);

                    // Removed by Mario Endara <*****@*****.**> (2004/11/04)
                    //					if (PortalSecurity.IsInRoles("Admins") || selfEdit)
                    if (PortalSecurity.HasEditPermissions(ModuleID) || PortalSecurity.HasAddPermissions(ModuleID) || selfEdit)
                    {
                        //We can edit

                        // Hide
                        RequiredPassword.Visible = false;
                        RequiredConfirm.Visible  = false;
                        EditPasswordRow.Visible  = true;
                        SaveChangesBtn.Visible   = true;
                        RegisterBtn.Visible      = false;

                        // Obtain a single row of event information
                        UsersDB accountSystem = new UsersDB();

                        RainbowUser memberUser = accountSystem.GetSingleUser(userName);

                        try {
                            NameField.Text    = memberUser.Name;
                            EmailField.Text   = memberUser.Email;
                            CompanyField.Text = memberUser.Company;
                            AddressField.Text = memberUser.Address;
                            ZipField.Text     = memberUser.Zip;
                            CityField.Text    = memberUser.City;

                            CountryField.ClearSelection();
                            if (CountryField.Items.FindByValue(memberUser.CountryID) != null)
                            {
                                CountryField.Items.FindByValue(memberUser.CountryID).Selected = true;
                            }
                            BindState();
                            StateField.ClearSelection();
                            if (StateField.Items.Count > 0 &&
                                StateField.Items.FindByValue(memberUser.StateID.ToString()) != null)
                            {
                                StateField.Items.FindByValue(memberUser.StateID.ToString()).Selected = true;
                            }

                            FaxField.Text          = memberUser.Fax;
                            PhoneField.Text        = memberUser.Phone;
                            SendNewsletter.Checked = memberUser.SendNewsletter;

                            //stores original password for later check
                            originalPassword = memberUser.GetPassword();
                            originalUserID   = memberUser.ProviderUserKey;
                        }
                        catch (System.ArgumentNullException error) {
                            // user doesn't exist
                        }
                    }
                    else
                    {
                        //We do not have rights to do it!
                        PortalSecurity.AccessDeniedEdit();
                    }
                }
                else
                {
                    BindState();

                    //No edit
                    RequiredPassword.Visible = true;
                    RequiredConfirm.Visible  = true;
                    EditPasswordRow.Visible  = false;
                    SaveChangesBtn.Visible   = false;
                    RegisterBtn.Visible      = true;
                }

                string termsOfService = portalSettings.GetTermsOfService;

                //Verify if we have to show conditions
                if (termsOfService.Length != 0)
                {
                    //Shows conditions
                    FieldConditions.Text  = termsOfService;
                    ConditionsRow.Visible = true;
                }
                else
                {
                    //Hides conditions
                    ConditionsRow.Visible = false;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the Click event of the SendPasswordBtn 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>
        private void SendPasswordBtn_Click(object sender, EventArgs e)
        {
            if (email.Text == string.Empty)
            {
                Message.Text    = "Please enter you email address";
                Message.TextKey = "SIGNIN_ENTER_EMAIL_ADDR";
                return;
            }
            // generate random password
            string randomPassword = RandomPassword.Generate(8, 10);

            CryptoHelper crypthelp = new CryptoHelper();
            UsersDB      usersDB   = new UsersDB();

            //Obtain single row of User information
            RainbowUser user = usersDB.GetSingleUser(email.Text);

            if (user != null)
            {
                string Pswrd;
                string AppName   = portalSettings.PortalName;
                bool   encrypted = Config.EncryptPassword;
                string Name      = user.Email;
                if (encrypted)
                {
                    Pswrd = randomPassword;
                    crypthelp.ResetPassword(Name, randomPassword);
                }
                else
                {
                    Pswrd = user.GetPassword();
                }
                crypthelp.ResetPassword(Name, randomPassword);
                string LoginUrl = Path.ApplicationFullPath + "DesktopModules/Admin/Logon.aspx?Usr="******"&Pwd=" +
                                  Pswrd + "&Alias=" + portalSettings.PortalAlias;
                MailMessage mail = new MailMessage();

                // [email protected]
                // Date 19 March 2003
                // We have to use a correct sender address,
                // because most SMTP servers reject it otherwise
                //jes1111 - mail.From = ConfigurationSettings.AppSettings["EmailFrom"].ToString();
                mail.From    = Config.EmailFrom;
                mail.To      = email.Text;
                mail.Subject = AppName + " - " + General.GetString("SIGNIN_SEND_PWD", "Send me password", this);

                StringBuilder sb = new StringBuilder();

                sb.Append(Name);
                sb.Append(",");
                sb.Append("\r\n\r\n");
                sb.Append(General.GetString("SIGNIN_PWD_REQUESTED", "This is the password you requested", this));
                sb.Append(" ");
                sb.Append(Pswrd);
                sb.Append("\r\n\r\n");
                sb.Append(General.GetString("SIGNIN_THANK_YOU", "Thanks for your visit.", this));
                sb.Append(" ");
                sb.Append(AppName);
                sb.Append("\r\n\r\n");
                sb.Append(General.GetString("SIGNIN_YOU_CAN_LOGIN_FROM", "You can login from", this));
                sb.Append(":");
                sb.Append("\r\n");
                sb.Append(Path.ApplicationFullPath);
                sb.Append("\r\n\r\n");
                sb.Append(General.GetString("SIGNIN_USE_DIRECT_URL", "Or using direct url", this));
                sb.Append("\r\n");
                sb.Append(LoginUrl);
                sb.Append("\r\n\r\n");
                sb.Append(
                    General.GetString("SIGNIN_URL_WARNING",
                                      "NOTE: The address above may not show up on your screen as one line. This would prevent you from using the link to access the web page. If this happens, just use the 'cut' and 'paste' options to join the pieces of the URL.",
                                      this));

                mail.Body       = sb.ToString();
                mail.BodyFormat = MailFormat.Text;

                SmtpMail.SmtpServer = Config.SmtpServer;
                SmtpMail.Send(mail);

                Message.Text =
                    General.GetString("SIGNIN_PWD_WAS_SENT", "Your password was sent to the addess you provided",
                                      this);
                Message.TextKey = "SIGNIN_PWD_WAS_SENT";
            }
            else
            {
                Message.Text =
                    General.GetString("SIGNIN_PWD_MISSING_IN_DB",
                                      "The email you specified does not exists on our database", this);
                Message.TextKey = "SIGNIN_PWD_MISSING_IN_DB";
            }
        }
        /// <summary>
        /// UpdateUser
        /// Autogenerated by CodeWizard 04/04/2003 17.55.40
        /// </summary>
        /// <param name="userID">The user ID.</param>
        /// <param name="name">The name.</param>
        /// <param name="company">The company.</param>
        /// <param name="address">The address.</param>
        /// <param name="city">The city.</param>
        /// <param name="zip">The zip.</param>
        /// <param name="countryID">The country ID.</param>
        /// <param name="stateID">The state ID.</param>
        /// <param name="phone">The phone.</param>
        /// <param name="fax">The fax.</param>
        /// <param name="password">The password.</param>
        /// <param name="email">The email.</param>
        /// <param name="sendNewsletter">if set to <c>true</c> [send newsletter].</param>
        public void UpdateUser(Guid userID, string name, string company, string address, string city,
                               string zip, string countryID, int stateID, string phone,
                               string fax, string password, string email, bool sendNewsletter)
        {
            RainbowUser user = MembershipProvider.GetUser(userID, true) as RainbowUser;

            user.Email          = email;
            user.Name           = name;
            user.Company        = company;
            user.Address        = address;
            user.Zip            = zip;
            user.City           = city;
            user.CountryID      = countryID;
            user.StateID        = stateID;
            user.Fax            = fax;
            user.Phone          = phone;
            user.SendNewsletter = sendNewsletter;

            MembershipProvider.ChangePassword(CurrentPortalSettings.PortalAlias, user.UserName, user.GetPassword(), password);
            MembershipProvider.UpdateUser(user);
        }