コード例 #1
0
        /// <summary>
        /// the method where we change the password of the user
        /// </summary>
        /// <param name="user"></param>
        /// <param name="pwd"></param>
        public static Users ChangePassword(Users user, string pwd)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(pwd))
                {
                    pwd = StringExtensions.GetRandomString(8);
                }

                var _salt = SecurityExtensions.GetSalt();

                var _encryptedPwd = SecurityExtensions.Encrypt(pwd + _salt.ToString());

                user.Salt     = _salt.ToString();
                user.Password = _encryptedPwd;

                return(user);
            }
            catch (Exception)
            {
                throw;
            }
        }