コード例 #1
0
        public bool ChangePassword([FromBody] User user, string newPassword)
        {
            if (!ModelState.IsValid)
            {
                return(false);
            }
            var result = _authenticate.ChangePassword(user, newPassword);

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Changes the password.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="oldPassword">The old password.</param>
        /// <param name="newPassword">The new password.</param>
        /// <returns>True if success; otherwise false</returns>
        public bool ChangePassword(string userName, string oldPassword, string newPassword)
        {
            if (String.IsNullOrEmpty(userName))
            {
                throw new ArgumentException("Value cannot be null or empty.", "userName");
            }
            if (String.IsNullOrEmpty(oldPassword))
            {
                throw new ArgumentException("Value cannot be null or empty.", "oldPassword");
            }
            if (String.IsNullOrEmpty(newPassword))
            {
                throw new ArgumentException("Value cannot be null or empty.", "newPassword");
            }

            return(_userAuthentication.ChangePassword(userName, oldPassword, newPassword));
        }