Example #1
0
        private bool DoActivate(string username, string activationCode, bool manualLogin)
        {
            bool userCreated = false;

            MembershipUser membershipUser = Membership.GetUser(username, false);

            if (membershipUser != null)
            {
                string           userId     = membershipUser.ProviderUserKey.ToString();
                AspnetMembership membership = AspnetMembership.FetchByID(new Guid(userId));

                if (membership.PasswordQuestion == activationCode || (manualLogin && ConfigurationManager.AppSettings["PromoActivationCode"].ToLower().Trim() == activationCode.ToLower().Trim()))
                {
                    membership.PasswordQuestion = "-";
                    membership.Save();
                    Roles.RemoveUserFromRole(username, "NotActivated");
                    Roles.AddUserToRole(username, "Basic");
                    DataObjectUser.CreateUser(UserDataContext.GetUserDataContext(), username);
                    UserProfile userProfile = UserProfile.GetProfile(username);
                    if (userProfile == null)
                    {
                        userProfile          = (UserProfile)UserProfile.Create(username);
                        userProfile.UserId   = new Guid(membershipUser.ProviderUserKey.ToString());
                        userProfile.Nickname = username;
                    }
                    Community.CreateUserProfileCommunity(UserDataContext.GetUserDataContext(), userProfile);
                    DataObjectUser.JoinCommunities(userId, _4screen.CSB.Common.SiteConfig.GetSiteContext(UserProfile.Current));
                    DataObjectUser.AddDefaultFriends(userId);
                    _4screen.CSB.Extensions.Business.IncentivePointsManager.AddIncentivePointEvent("USER_ACTIVATE", UserDataContext.GetUserDataContext());
                    SetProfileDefaults(new Guid(userId));
                    userCreated = true;
                }
                else if (membership.PasswordQuestion != activationCode)
                {
                    lblInfo.Text       += language.GetString("MessageActivatCodeInvalid");
                    pnlError.Visible    = true;
                    pnlActivate.Visible = false;
                }
            }
            else
            {
                lblInfo.Text       += language.GetString("MessageActivatUserInvalid");
                pnlError.Visible    = true;
                pnlActivate.Visible = false;
            }

            return(userCreated);
        }