当前位置: 首页>>代码示例>>C#>>正文


C# User.ValidatePassword方法代码示例

本文整理汇总了C#中umbraco.BusinessLogic.User.ValidatePassword方法的典型用法代码示例。如果您正苦于以下问题:C# User.ValidatePassword方法的具体用法?C# User.ValidatePassword怎么用?C# User.ValidatePassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在umbraco.BusinessLogic.User的用法示例。


在下文中一共展示了User.ValidatePassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidateUser

        /// <summary>
        /// Verifies that the specified user name and password exist in the data source.
        /// </summary>
        /// <param name="username">The name of the user to validate.</param>
        /// <param name="password">The password for the specified user.</param>
        /// <returns>
        /// true if the specified username and password are valid; otherwise, false.
        /// </returns>
        public override bool ValidateUser(string username, string password)
        {
            // we need to wrap this in a try/catch as passing a non existing 
            // user will throw an exception
            try
            {
                User user = new User(username);
                if (user != null && user.Id != -1)
                {
                    if (user.Disabled) return false;
                    else return user.ValidatePassword(EncodePassword(password));
                }
            }
            catch
            {
                // nothing to catch here - move on
            }

            return false;
        } 
开发者ID:Jeavon,项目名称:Umbraco-CMS,代码行数:28,代码来源:UsersMembershipProvider.cs

示例2: ChangePassword

        /// <summary>
        /// Processes a request to update the password for a membership user.
        /// </summary>
        /// <param name="username">The user to update the password for.</param>
        /// <param name="oldPassword">The current password for the specified user.</param>
        /// <param name="newPassword">The new password for the specified user.</param>
        /// <returns>
        /// true if the password was updated successfully; otherwise, false.
        /// </returns>
        public override bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            if (!User.validateCredentials(username, oldPassword))            
                return false;

            ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, newPassword, true);
            OnValidatingPassword(args);

            if (args.Cancel)
                if (args.FailureInformation != null)
                    throw args.FailureInformation;
                else
                    throw new MembershipPasswordException("Change password canceled due to new password validation failure.");

            User user = new User(username);
            string encodedPassword = EncodePassword(newPassword);            
            user.Password = encodedPassword;            
            return (user.ValidatePassword(encodedPassword)) ? true : false;
        }
开发者ID:Jeavon,项目名称:Umbraco-CMS,代码行数:28,代码来源:UsersMembershipProvider.cs


注:本文中的umbraco.BusinessLogic.User.ValidatePassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。