Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom 713 posts 952 karma points
    Apr 08, 2011 @ 07:57
    Tom
    0

    Umb 4.7 BUG Member.cs

    Hi Guys in Member.cs in umb 4.7 there is a bug in the MakeNew method line: 217 on

                var loginName = (!String.IsNullOrEmpty(LoginName)) ? LoginName : Name;
                // Test for e-mail
                if (Email != "" && Member.GetMemberFromEmail(Email) != null)
                    throw new Exception(String.Format("Duplicate Email! A member with the e-mail {0} already exists", Email));
                else if (Member.GetMemberFromLoginName(LoginName) != null)
                    throw new Exception(String.Format("Duplicate User name! A member with the user name {0} already exists", Name));
    

    if LoginName is null or empty it populates the var loginName using name.. the product in then down on line 221.. when checking Member.GetMemberFromLoginName(LoginName) != null it's not using the loginName var it's using the upper.. and hence blowing up if LoginName is empty and throwing the duplicate user name exception..

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Apr 08, 2011 @ 08:11
    Jan Skovgaard
    1

    Hi Tom

    Good to see you're reporting a bug :)

    Please add it to the issue tracker on codeplex if it has not already been added - then the core team will have the option to take the proper actions.

    /Jan

  • Tom 713 posts 952 karma points
    Apr 08, 2011 @ 08:13
    Tom
    0

    Thanks for all your replies to my questions.. I've responded to the other 4.7 quesiton about membership.. thank you Jan most appreciated

  • Fredrik Esseen 594 posts 830 karma points
    Apr 08, 2011 @ 08:15
    Fredrik Esseen
    1

    I think this bug is already reported:

    http://umbraco.codeplex.com/workitem/29885

    And if I recall right the MakeNew method is obsolete.
    U should use System.Web.Security.Membership.CreateUser.

    But this bug should really be fixed as setting member properties is not that easy as MakeNew with the Membership method.

    Edit: Realized not the same issue. Please disregard!

  • Tom 713 posts 952 karma points
    Apr 08, 2011 @ 08:20
    Tom
    0

    Hi Froad.. but how would i achieve something like this scenario using CreateUser? what would need to change:

    protected void CreatedUser(Object sender, EventArgs e)
                   
    {
                           
    var UserNameTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
                           
    string username = UserNameTextBox.Text;

                           
    var User = Membership.GetUser(username);
                           
    var member = new Member((int)User.ProviderUserKey);

                           
    var FullNameProperty = member.getProperty("fullName");
                           
    var FullNameTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FullName");
                           
    FullNameProperty.Value = FullNameTextBox.Text;

                           
    var DateOfBirthProperty = member.getProperty("dateofBirth");
                           
    var DateOfBirthTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("DateOfBirthTextBox");

                           
    DateOfBirthProperty.Value = DateTime.ParseExact(DateOfBirthTextBox.Text, "d/M/yyyy", null, System.Globalization.DateTimeStyles.AllowWhiteSpaces);

                           
    var NewsletterOptInProperty = member.getProperty("newsletterOptIn");
                           
    var SubscribeCheckBox = (CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SubscribeCheckBox");
                           
    NewsletterOptInProperty.Value = SubscribeCheckBox.Checked ? 1 : 0;

                           
    var CountryProperty = member.getProperty("country");
                           
    CountryProperty.Value = ((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("CountryDropDownList")).SelectedValue;

                           
    var StateProperty = member.getProperty("state");
                           
    StateProperty.Value = ((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("StateDropDownList")).SelectedValue;

                           
    Roles.AddUserToRole(member.LoginName, "Public");
                            member
    .AddGroup(1068);  // Group ID
                            member
    .Email = member.LoginName;

                            member
    .Save();
                   
    }


  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies