Exemple #1
0
        public ActionResult Manage(AccountManageModel model)
        {
            if (!string.IsNullOrEmpty(model.PasswordOld))
            {
                int id = this.GetFormsAuthenticationID();
                Account account = this.dataRepository.GetAccount(id);

                string encryptedPasswordNew = SecurityUtil.GenerateEncryptedPassword(model.PasswordOld, account.PasswordSalt).Password;

                if (account.Password == encryptedPasswordNew)
                {
                    if (!string.IsNullOrEmpty(model.PasswordNew) && model.PasswordNew == model.PasswordNewConfirm)
                    {
                        // create new encrypted password using the same SALT
                        account.Password = SecurityUtil.GenerateEncryptedPassword(model.PasswordNew, account.PasswordSalt).Password;
                    }
                    this.dataRepository.Update(account);

                }
                else
                {
                    //
                    // TODO: display error message
                    //
                }
            }
            else
            {
                //
                // TODO: display error message
                //
            }

            //
            // TODO: update account
            //
            return View(model);
        }
Exemple #2
0
 public ActionResult Manage()
 {
     int id = this.GetFormsAuthenticationID();
     Account account = this.dataRepository.GetAccount(id);
     AccountManageModel model = new AccountManageModel();
     model.Name = account.Name;
     model.Email = account.Email;
     model.SendEmailNotifications = account.SendEmailNotifications;
     return View(model);
 }