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


C# User.Save方法代码示例

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


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

示例1: UnlockUser

 /// <summary>
 /// Clears a lock so that the membership user can be validated.
 /// </summary>
 /// <param name="userName">The membership user to clear the lock status for.</param>
 /// <returns>
 /// true if the membership user was successfully unlocked; otherwise, false.
 /// </returns>
 public override bool UnlockUser(string userName)
 {
     try
     {
         User user = new User(userName);
         user.Disabled = false;
         user.Save();
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:21,代码来源:UsersMembershipProvider.cs

示例2: CreateSection

        private void CreateSection()
        {
            this.BulletedList1.Items.Add(new ListItem("Creating the section."));

            var sectionService = ApplicationContext.Services.SectionService;

            //Try & find a section with the alias of "nuget"
            var ecSection = sectionService.GetSections().SingleOrDefault(x => x.Alias == "eventCalendar");

            //If we can't find the section - doesn't exist
            if (ecSection == null)
            {
                //So let's create it the section
                sectionService.MakeNew("EventCalendar", "eventCalendar", "icon-calendar-alt");
                this.BulletedList1.Items.Add(new ListItem("Done creating the section."));

                //Add the section to the allowed once for the admin
                var admin = new User(0);
                if (!admin.Applications.Any(x => x.alias == "eventCalendar"))
                {
                    admin.AddApplication("eventCalendar");
                    admin.Save();
                }
                this.BulletedList1.Items.Add(new ListItem("Added Admin to the section."));
            }            
        }
开发者ID:nhaberl,项目名称:EventCalendarBelle,代码行数:26,代码来源:installer.ascx.cs

示例3: 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, false);
            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;            
            user.Save();
            return (user.ValidatePassword(encodedPassword)) ? true : false;
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:29,代码来源:UsersMembershipProvider.cs

示例4: PerformChangePassword

        /// <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>
        /// <remarks>
        /// During installation the application will not be configured, if this is the case and the 'default' password 
        /// is stored in the database then we will validate the user - this will allow for an admin password reset if required
        /// </remarks>
        protected override bool PerformChangePassword(string username, string oldPassword, string newPassword)
        {


            if (ApplicationContext.Current.IsConfigured == false && oldPassword == "default"
                || ValidateUser(username, oldPassword))
            {
                var args = new ValidatePasswordEventArgs(username, newPassword, false);
                OnValidatingPassword(args);

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

                var user = new User(username);
                //encrypt/hash the new one
                string salt;
                var encodedPassword = EncryptOrHashNewPassword(newPassword, out salt);

                //Yes, it's true, this actually makes a db call to set the password
                user.Password = FormatPasswordForStorage(encodedPassword, salt);
                //call this just for fun.
                user.Save();

                return true;    
            }

            return false;

        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:46,代码来源:UsersMembershipProvider.cs


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