示例#1
0
        /// <summary>
        /// Helper function to update a user's email address.
        /// Syncs with both the YAF DB and Membership Provider.
        /// </summary>
        /// <param name="userID">The user ID.</param>
        /// <param name="newEmail">The new email.</param>
        /// <returns>
        /// The update email.
        /// </returns>
        public static bool UpdateEmail(int userID, string newEmail)
        {
            object providerUserKey = GetProviderUserKeyFromID(userID);

            if (providerUserKey == null)
            {
                return(false);
            }

            MembershipUser user =
                GetUser(ObjectExtensions.ConvertObjectToType(providerUserKey, Config.ProviderKeyType));

            user.Email = newEmail;

            YafContext.Current.Get <MembershipProvider>().UpdateUser(user);

            LegacyDb.user_aspnet(
                YafContext.Current.PageBoardID, user.UserName, null, newEmail, user.ProviderUserKey, user.IsApproved);

            return(true);
        }
示例#2
0
        /// <summary>
        /// Approves the user.
        /// </summary>
        /// <param name="userID">The user id.</param>
        /// <returns>
        /// The approve user.
        /// </returns>
        public static bool ApproveUser(int userID)
        {
            var providerUserKey = GetProviderUserKeyFromID(userID);

            if (providerUserKey == null)
            {
                return(false);
            }

            var user = GetUser(ObjectExtensions.ConvertObjectToType(providerUserKey, Config.ProviderKeyType));

            if (!user.IsApproved)
            {
                user.IsApproved = true;
            }

            YafContext.Current.Get <MembershipProvider>().UpdateUser(user);
            YafContext.Current.GetRepository <User>().Approve(userID);

            return(true);
        }
示例#3
0
        /// <summary>
        /// Approves the user.
        /// </summary>
        /// <param name="userID">The user id.</param>
        /// <returns>
        /// The approve user.
        /// </returns>
        public static bool ApproveUser(int userID)
        {
            object providerUserKey = GetProviderUserKeyFromID(userID);

            if (providerUserKey != null)
            {
                MembershipUser user =
                    GetUser(ObjectExtensions.ConvertObjectToType(providerUserKey, Config.ProviderKeyType));
                if (!user.IsApproved)
                {
                    user.IsApproved = true;
                }

                YafContext.Current.Get <MembershipProvider>().UpdateUser(user);
                LegacyDb.user_approve(userID);

                return(true);
            }

            return(false);
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TypedUserFind"/> class.
 /// </summary>
 /// <param name="row">
 /// The row.
 /// </param>
 public TypedUserFind(DataRow row)
 {
     this.UserID           = row.Field <int?>("UserID");
     this.BoardID          = row.Field <int?>("BoardID");
     this.Name             = row.Field <string>("Name");
     this.Password         = row.Field <string>("Password");
     this.Email            = row.Field <string>("Email");
     this.Joined           = row.Field <DateTime?>("Joined");
     this.LastVisit        = row.Field <DateTime?>("LastVisit");
     this.IP               = row.Field <string>("IP");
     this.NumPosts         = row.Field <int?>("NumPosts");
     this.TimeZone         = row.Field <int?>("TimeZone");
     this.Avatar           = row.Field <string>("Avatar");
     this.Signature        = row.Field <string>("Signature");
     this.AvatarImage      = row.Field <byte[]>("AvatarImage");
     this.RankID           = row.Field <int?>("RankID");
     this.Suspended        = row.Field <DateTime?>("Suspended");
     this.LanguageFile     = row.Field <string>("LanguageFile");
     this.ThemeFile        = row.Field <string>("ThemeFile");
     this.Flags            = row.Field <int?>("Flags");
     this.PMNotification   = row.Field <bool?>("PMNotification");
     this.Points           = row.Field <int?>("Points");
     this.IsApproved       = row.Field <bool?>("IsApproved");
     this.IsActiveExcluded = row.Field <bool?>("IsActiveExcluded");
     this.UseMobileTheme   = row.Field <bool?>("OverrideDefaultThemes");
     this.AvatarImageType  = row.Field <string>("AvatarImageType");
     this.AutoWatchTopics  = row.Field <bool?>("AutoWatchTopics");
     this.TextEditor       = row.Field <string>("TextEditor");
     this.DisplayName      = row.Field <string>("DisplayName");
     this.Culture          = row.Field <string>("Culture");
     this.NotificationType = row.Field <int?>("NotificationType");
     this.DailyDigest      = row.Field <bool?>("DailyDigest");
     this.IsGuest          = row.Field <bool>("IsGuest");
     this.ProviderUserKey  = this.IsGuest ? null : ObjectExtensions.ConvertObjectToType(
         row.Field <string>("ProviderUserKey"), Config.ProviderKeyType);
 }
 /// <summary>
 /// get the membership user from the providerUserKey
 /// </summary>
 /// <param name="providerUserKey">
 /// The provider user key.
 /// </param>
 /// <returns>
 /// The get membership user by key.
 /// </returns>
 public static MembershipUser GetMembershipUserByKey(object providerUserKey)
 {
     // convert to provider type...
     return(GetUser(ObjectExtensions.ConvertObjectToType(providerUserKey, Config.ProviderKeyType)));
 }